Android :: Acquiring Wake Lock From Broadcast Receiver?
Aug 13, 2010
I have a problem. I am trying to make a broadcast receiver acquire a wake lock so my alarm will wake the phone from sleep mode.
In the broadcast receiver below, the program crashes with "source not found" on line "sCpuWakeLock.acquire(); when the class "AlarmAlertWakeLock" is called by AlarmReceiver.
Any idea what's going on? Is there a better way to do what I'm trying to do?
In one file:
CODE:..............
In a separate file:
CODE:......................
View 1 Replies
Aug 13, 2010
I am trying to acquire a wake lock in a broadcast receiver so that my alarm clock application can wake the phone from sleep. It crashes at the following line in the code below:
CODE:...........
Any ideas what's going on?
Is there a better way to do this?
CODE:...................
View 2 Replies
View Related
Sep 28, 2009
trying to create a broadcast receiver which responds to system events and change system settings. I don't need any interaction from the user so I don't need an activity and have been trying to do everything through the manifest file. I've put a log event into my onReceive method but it never logs anything so I'm presuming my method is never called. I've tried this with both the 1.5 and 1.6 SDKs. I was hoping somebody could have a look at my code please and let me know if there are any problems.
View 2 Replies
View Related
Jul 9, 2009
I am trying to start TTS from a broadcast receiver and it as document an intent receiver can't bind the service. Is there a work around, I can't figure out how to start the service using startService(Intent, Bundle).
View 4 Replies
View Related
Feb 12, 2010
A WAP PUSH (Broadcast)receiver basically doesn't need any UI. It is a silence application which handles the Push messages based on actions/ mimetype without needing any intreaction with user, I've tried to test it in a SMS receiver by removing the Activity from the project and it stopped receiving the SMS messages. My question: Does all android applications "MUST" define a activity? Is there a way to hide it?
View 5 Replies
View Related
Jul 23, 2010
I am working on one project where i am using broadcast receiver in one of my activity to capture the incomming call and its works fine. when one of my other activity is open and that time if call is come then my broadcast receiver is fail to respond. can any one help me for this ? or its nessesorry to declare broadcast receiver in all my activity to do some comman task.
View 5 Replies
View Related
Dec 2, 2009
I am making a widget that needs a broadcast receiver, like the one in com.example.android.apis.appwidget.ExampleBroadcastReceiver. However, the example defines Intent.ACTION_TIMEZONE_CHANGED in the manifest, but there are some that do not allow this. For example, Intent.ACTION_TIME_TICK says "You can not receive this through components declared in manifests, only by exlicitly registering for it with Context.registerReceiver(). "
So I removed the manifest declarations and tried replacing the AppWidgetProvider.onEnabled function that was in the example with a call like the following: context.registerReceiver(myReceiver, new IntentFilter(Intent.ACTION_TIME_TICK));
(where "myReceiver" is an instance of the receiver I want.) However, when I try to run the code, I get the following error:
Unable to start receiver...android.content.ReceiverCallNotAllowedException: IntentReceiver components are not allowed to register to receive intents.
Any way to get this broadcast receiver working from a widget?
View 3 Replies
View Related
Jul 29, 2009
I am broadcasting an Intent from an activity. Can we make another application as a receiver. So that it will get invoked when that specific intent is broadcasted.
View 2 Replies
View Related
Jan 6, 2010
I wish to listen to android.intent.action.BOOT_COMPLETED. However I am not getting the broadcast intent, if I specify com.test.BootBroadcastReceiver in the manifest. When I change this value to simply BootBroadcastReceiver, then I am getting the broadcast intent.
<receiver android:name="BootBroadcastReceiver" android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
My package in the manifest file is:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test"
And the BootBroadcastReceiver resides in this package. What is the reason behind this?
View 2 Replies
View Related
Aug 17, 2009
I have an application that uses an extended Broadcast Receiver class inside the Activity. I have the extended Broadcast Receiver class as a member variable of the Activity class. But it looks like the receiver references keep changing between its construction and 'on Receive' method call. I would like to understand this better. Here are some details. public class MyEventReceiver extends Broadcast Receiver
View 3 Replies
View Related
Oct 3, 2009
I was wondering if its possible to have a broadcast receiver to listen when the app its in launches.I tried doing by creating a BroadcastReceiver to listen for the android.intent.action.MAIN action but it never gets called?Is there something I need to do or a different action I should be listening for?
View 3 Replies
View Related
May 1, 2010
I have here two applications in two different projects in eclipse. One application
(A) defines an activity
(A1) which is started first. Then i start from this activity the second activity
(B1) in the second project
(B). This works fine.
Unfortunately, the message is never received. Although the method in activity A1 is called, i never receive an intent in B1.
View 1 Replies
View Related
Jun 13, 2009
I created a BroadcastReceiver and configured it with an android.provider.Telephony.SMS_RECEIVED action filter so it is called everytime the phone receives a text.Is there some event/action or other way for my application to be notified whenever the phone sends a text (preferably independent of the application that sends it)?So far the only option I see is to poll the content provider for content://sms/sent which doesn't even give me all sent texts because applications can choose not to put it there.
View 1 Replies
View Related
Oct 24, 2010
The symptom: I have a broadcast receiver that listen to sms, when a sms is received, i call an activity to display. It works all fine if the screen is on and not locked. But when screen is locked, and as soon as i received the sms, the activity popup for a second then disappeared and I use the code to unlock the screen.
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
I think it might be the competitions with phone default sms program (the sms default program shows a notification only). I am wondering is there a way to set priority to broadcast receivers or even the activity that receiver stared, to avoid the conflicts between multiple receivers. or set orders to execute one by one? I have tried to thread.sleep my receiver for a second, still not working.
View 2 Replies
View Related
Dec 15, 2009
I need to be able to handle/catch Intents while my Activity is closed. So I am looking at either a Service or a BroadcastReceiver. Is it possible to "receive" intents to a service itself? I tried to search, but could not find anything helpful. With a BroadcastReceiver, I am not exactly sure how that works outside of an Activity. Does it depend on the Activity being open/running? Can it run by itself?
Let's say that my Activity is killed by Android(or a task killer app), does the BroadcastReceiver still receive intents and process them? I have used a BroadcastReceiver as a widget, but I do not want to use a widget this time. My goal is to have the user open the Activity to set some options. From there, they would be able to close the Activity, but I would still be able to process Intents that were sent out by the system. I am still fairly new to Android development, so I could be so far away from where I need to be.
View 1 Replies
View Related
Oct 11, 2010
I'm trying to receive SMS using broadcast receiver. MySMSReceiver :
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.util.Log;
public class MySmsReceiver extends BroadcastReceiver {
/** Tag string for our debug logs */
private static final String TAG = "MySmsReceiver";
@Override
public void onReceive(Context context, Intent intent) {
Log.i(TAG, "Recieved a message");
Bundle extras = intent.getExtras();
if (extras == null)
return;
Object[] pdus = (Object[]) extras.get("pdus");
for (int i = 0; i < pdus.length; i++) {
SmsMessage message = SmsMessage.createFromPdu((byte[]) pdus[i]);
String fromAddress = message.getOriginatingAddress();
String fromDisplayName = fromAddress;
Log.i(TAG, fromAddress);
Log.i(TAG, fromDisplayName);
Log.i(TAG, message.getMessageBody().toString());
break; } } }
and added in Mainfest file
<receiver android:name=".MySmsReceiver" android:enabled="false">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<uses-permission android:name="android.permission.RECEIVE_SMS" />
But when I run this application and send a SMS using emulator it shows following logs in logcat
10-12 00:14:53.082: VERBOSE/Telephony(1032): getOrCreateThreadId uri: content://mms-sms/threadID?recipient=9898989898
10-12 00:14:53.203: VERBOSE/Telephony(1032): getOrCreateThreadId cursor cnt: 1
10-12 00:14:53.432: DEBUG/Mms:app(1032): getSmsNewMessageNotificationInfo: count=4, first addr=9898989898, thread_id=3
10-12 00:14:53.482: WARN/NotificationService(62): STOP command without a player
10-12 00:14:53.562: DEBUG/MediaPlayer(62): Couldn't open file on client side, trying server side
10-12 00:14:53.582: ERROR/MediaPlayerService(34): Couldn't open fd for content://settings/system/notification_sound
10-12 00:14:53.592: ERROR/MediaPlayer(62): Unable to to create media player
10-12 00:14:53.643: WARN/NotificationService(62): error loading sound for content://settings/system/notification_sound
10-12 00:14:53.643: WARN/NotificationService(62): java.io.IOException: setDataSource failed.: status=0x80000000
10-12 00:14:53.643: WARN/NotificationService(62): at android.media.MediaPlayer.setDataSource(Native Method)
10-12 00:14:53.643: WARN/NotificationService(62): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:716)
10-12 00:14:53.643: WARN/NotificationService(62): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:671)
10-12 00:14:53.643: WARN/NotificationService(62): at com.android.server.NotificationPlayer$CreationAndCompletionThread.run(NotificationPlayer.java:8)
View 1 Replies
View Related
Sep 10, 2010
I have create a receiver which receive on phone state change I have register it in XML by "android.intent.action.PHONE_STATE"
But sometime it don't receive any broadcast message
log mesages are:::
09-10 11:20:36.968: WARN/ActivityManager(74): Timeout of broadcast BroadcastRecord{43347258 android.intent.action.PHONE_STATE - receiver=android.os.BinderProxy@4334ebd0
09-10 11:20:36.968: WARN/ActivityManager(74): Receiver during timeout: ResolveInfo{432dd748 com.callHandller.PhoneStateReciever p=0 o=0 m=0x108000}
09-10 11:20:36.968: INFO/Process(74): Sending signal. PID: 2223 SIG: 9
09-10 11:20:36.988: ERROR/JavaBinder(74): !!! FAILED BINDER TRANSACTION !!!
09-10 11:20:37.008: INFO/ActivityManager(74): Process com.callHandller (pid 2223) has died.
09-10 11:20:37.008: INFO/WindowManager(74): WIN DEATH: Window{4324f470 com.callHandller/com.incallHandller.callHandler paused=false}
09-10 11:20:37.958: WARN/ActivityManager(74): Activity destroy timeout for HistoryRecord{4321c7c0 com.callHandller/com.incallHandller.callHandler}
09-10 11:20:42.288: DEBUG/dalvikvm(136): GC freed 2543 objects / 143320 bytes in 179ms
Here com.callhandller is my application package where I have Receiver...
View 3 Replies
View Related
Jul 11, 2010
So, I added the receiver (contained in application) in the manifest. Broadcast doesn't fire my broadcast receive.
<receiver android:name="mypkg.IncomingCallReceiver">
<intent-filter>
<action android:name="android.telephony.TelephonyManager.ACTION_PHONE_STATE_CHANGED"/ >
</intent-filter>
View 4 Replies
View Related
Mar 25, 2010
I am trying to understand the use of the broadcast receiver and the way of activate it. There's two ways isn't it? Register it from an activity or declare it in the manifest. So my question is: If I code a broadcast receiver which is watching incoming messages and I register it in the manifest, when a message comes my broadcast receiver will catch it automatically although any activity of my app had registered it. In a nutshells, I don't have to activate it so it works, only register it either in the manifest or in an activity.
View 2 Replies
View Related
Dec 27, 2009
I have a service that gets updated every x minutes depending on the user preferences. This service connects to a web service and pulls some data. If during an update the user has no connection I register my receiver and start listening for changes (ConnectivityManager.CONNECTIVITY_ACTION), the thing is that onReceive () only gets called on every update instead of firing onReceived as soon as I plug the connection back in. Have I understood the concept of Broadcast Receiver wrong? Is it not suppose to send a notification as soon as it detetcs a change in the connection?
View 4 Replies
View Related
Jun 23, 2010
I am starting to develop a new app and I am a bit confused about the structure I need to give it.I need to react to broadcast intents, so I placed a broadcast received in the manifest. Every single intent produces an action to be performed. Now the first question: should I start a service (maybe with non_sticky option?) or should I start a thread (or an async task) directly from the broadcast receiver? If I start a service, should I do all the stuff in its body, or should it start a thread. I should do the heavy job in a thread if there are time consuming operations, but what if the gui of my application is just an activity with the options and a button to start the service. What is the point in keeping the main thread busy? Do I risk to be killed for not being responsive? I read here and there that I can update the gui from a background thread. Can I do that even if it is started from a service? The AsyncTask's onProgressUpdate is said to run in the application main thread, but if the application is made of different activities, who tells me which activity is the user looking at while the thread is doing all its long work? The user could change activity in the meanwhile and then the update would be unuseful.I know it's (quite) a lot of questions, but I need to get some clarifications before taking the wrong path.
View 5 Replies
View Related
Jul 3, 2009
I've been modifying things All day trying to get this to work. I have a broadcast receiver that receives a "boot completed" signal. the onReceive method works! Well at least it sends output to the log. The problem is that that method is responsible for creating a AlarmService, to start call a different class every minute. That other class never has it's onReceive method called...
AndroidManifest snippet: <receiver android:name=".FmiBootup">
<!-------------THIS WORKS FINE------------->
<intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /
View 6 Replies
View Related
May 6, 2010
I'm currntly struggling with an Android problem whose answer is maybe simple.(I'm new in Android developing)I have a main activity that builds a TabHost with two Tabs (each represents another Activity)As far as I know I can't receive broadcast messages within an activity - so the only thing I could do is to start a new activity out of my Broadcast Receiver. But instead I want to change my Tab View or show the alert.Are there any possibilities to access an existing Activity from a broadcast receiver class?
View 1 Replies
View Related
May 28, 2010
I am trying to launch the Main Activity from a broadcast receiver. Can anyone guide me as to how I can do it? I always get "Process is Bad" message.
View 1 Replies
View Related
Sep 17, 2010
I have a singleton which stores some prudent information about the user of my application. At the moment, it stores the user's login and the user's location.The location is found via a Service. At the moment, the Service references my singleton directly to stuff the longitude and latitude into it. I would like to use a Broadcast Receiver to send a broadcast that the singleton hears and uses to update the values, instead. However, to register the Broadcast Receiver, I need a Context in my singleton. What is the slickest way to achieve what I'm wanting. Is Broadcast Receiver possibly not the appropriate object? Also, what problems am I looking at with using a singleton? I assume that Android will possibly reclaim this memory at any given time (which would obviously be bad); so how can I prevent that? Would passing in the application's Context and storing it in a member variable thwart this? The Android documentation states: "But, the life cycle of a static is not well under your control; so to abide by the life-cycle model, the application class should initiate and tear down these static objects in the onCreate() and on Terminate() methods of the Application Class," but I'm not entirely sure how to accomplish this.
View 1 Replies
View Related
Nov 3, 2010
I use pending_intents and a broadcast_receiver for pending events processing. When the broadcast_receiver receives an intent it creates an instance of a ringtone with STREAM_NOTIFICATION and `play()' it. But sounds is late for a few dozen minutes. I have checked that the pending_intens are come in proper time and the broadcast_receiver processes them properly. It seems there is a problem with playing notifications while a phone stay in sleep mode (screen is off). Somebody know how to bypass the problem?
View 1 Replies
View Related
May 5, 2009
I have developed a music player and the application defines a broadcast receiver that handles MediaButton intents:
<application...>
<receiver android:name="MediaButtonIntentReceiver"> <intent-filter android:priority="32000"> <action android:name="android.intent.action.MEDIA_BUTTON"/> </intent-filter> </receiver>
</application>
which works well. My question is if it was possible to change the priority of this receiver from within the settings activity of my application. That way people could choose if they wanted my player as default handler of the headset buttons or not.
View 5 Replies
View Related
Sep 10, 2009
I want to access message data from the class which extends BroadcastReceiver but the problem is we need Activity. So I create the object of Activity by Activity a=new Activity() but it seems there is some issue with it. So please take a look at it. The code is as follow
try { Uri allMessage = Uri.parse("content://sms/");
Log.e("1", "1"); Activity a=new Activity(); Log.e("2", "2");
if(allMessage==null) { Log.e("null", "null");
} Cursor c = a.managedQuery(allMessage, null, null, null, null);
Log.e("3", "3"); String logs=""; Log.e("first", String.valueOf(c.getColumnCount()));
while (c.moveToNext()) { String row = ""; int index=c.getColumnCount();
//row = c.getString(2) + "-" + c.getString(11) + "-" + c.getString(;
for(int i=0;i<index;i++) row=row+"column1" +c.getString(i);
logs = logs + row + " "; } Log.e(getClass().getSimpleName(), logs );
} catch(Exception e) { Log.e("Exception",e.toString());
}
View 2 Replies
View Related
Nov 9, 2010
I've a simple Main Activity which has to stop till an SMS is received.How can I launch a Method from the MainActivity within the BroadCast Receivers onReceive() Method? Is there away with Signal and Wait? Can I pass something with a pending Intent, or how can i realise this communication?
View 2 Replies
View Related
Jan 1, 2010
I would like to sample my GPS location periodically, say, every 10 minutes. I'm assuming that the best way to do this would be to use the LocationManager class with the method: public void requestLocationUpdates (String provider, long minTime, float minDistance, PendingIntent intent) That would broadcast the specified intent that I could then receive in a broadcast receiver in my application. My question is, if I call this method from an activity, will the broadcasts stop when the process that called the requestLocationUpdate() is killed, or will this registration remain active so that I can continue to get location updates? Do I need to leave a service running to be able to keep the location updates coming when a user moves to different applications?
View 1 Replies
View Related