Android :: BroadcastReceiver - Sms Received

Dec 29, 2009

I'd like my app to catch incoming SMS messages. There are a few examples of this around. Looks like we just need to do this:


Is this correct? I'm sending my phone some sms messages, but the log statement never gets printed. I do have some other SMS applications installed on the phone, which display a popup when the sms is received - are they somehow blocking the intent from getting passed down to my app, they are just consuming it completely?


Android :: SMS Using BroadcastReceiver

Mar 5, 2010

I am writing my own sms receiver app and i want it to catch all the sms using a broadcast receiver. This on its own, is no problem, but i want to be able to stop the message being passed to the messaging app.

View 2 Replies View Related

Android :: How Do I Do A StartActivity In BroadcastReceiver?

Apr 7, 2009

My use case is to launch one of settings app screen when I receive a certain event in idle state. For which, I added my new intent to PhoneAppBroadcastReceiver() in (looks like this receiver handles the misc intents) But when i call startActivity(), The phone seems to go into a panic ex. startActivity(new Intent(this, NetworkSetting.class)); My questions are is this the right approach to go about ? If so 1. How can I launch the activity inside of broadcastReceiver? secondly 2. How do i verify if the activity i want to start is already started?Can the NEW_TASK_LAUNCH be used to verify this ,

View 2 Replies View Related

Android :: BroadcastReceiver To Get Incoming SMS

Sep 21, 2010

I have written an application to read all incoming SMS and if the SMS contains certain string, I will also send a copy of the message to my another phone for backup purposes.

I used the reference from the following website:

It uses BroadcastReceiver to get the incoming SMS, but when I tried to send it using the following method:


It always crashes. Any idea how to resolve it? Is it because of using BroadcastReceiver.

View 4 Replies View Related

Android :: AppWidgetProvider And BroadcastReceiver

Oct 2, 2009

I have an app widget that extends an AppWidgetProvider to create an application widget.

I would like the application widget to be idle until an activity in my app runs; actually when a service in my app is started.

Once that service is started, I need to "wake up" the application widget and communicate with it (i.e. tell it things to display).

So I see that AppWidgetProvider simply extends BroadcastReceiver -- so does that mean:

1. I need to call registerReceiver in my service and tell it to filter for certain kinds of events?

2. Can I even do #1, or will an AppWidgetProvider *only* accept ACTION_APPWIDGET_* intents?

3. If #2 is correct, how can I communicate or "wake up" / trigger the application widget?

4. Can I send events to my app widget using sendBroadcast( intent )?

Then, my app widget has some buttons on it, I need to send an intent back to the application (or service). I see you can do that with PendingIntents, but if i send the different intents it to the same Activity, it seems to re-use the first created pending intent.

View 2 Replies View Related

Android :: App Contains BroadcastReceiver And Activity

Aug 6, 2009

I want to start a project which contains a BroadcastReceiver and an Activity. The BroadcastReceiver doesn't communicate with the activity. But they share a same resource. Can i do it in only one Project (that means, i use only 1 apk to install both BroadcastReceiver and the Activity on my phone), or i have to develope them seperately in 2 projects.

View 3 Replies View Related

Android :: BroadcastReceiver On Service

Aug 28, 2009

Can I Receive a Broadcast from a Service? It seem I have to extend BroadcastReceiver to receive broadcasts but I'm already extending Service and I can't extend 2 classes. Do I set up an additional Activity to receive broadcasts and then just pass stuff to the already running Service. And if so, how to I pass additional info to an existing Service? Is there a better way?

View 4 Replies View Related

Android :: BroadcastReceiver And AbortBroadcast

Jun 22, 2010

How can I best implement a BroadcastReceiver that may need to "consume" the current broadcast (via abortBroadcast()), but it first needs to perform some non-trivial work to determine whether or not the broadcast should be consumed.

The problem is that if the non-trivial work takes more than 10 seconds then the receiver is considered to be blocked by the system and may be killed.

I realise that long-running operations should not be performed in the onReceive() method of receivers for that very reason, and should instead be handed-off to an appropriate service. However, if the current broadcast is to be consumed, then the abortBroadcast() method must be called within the onReceive() method before it returns. If some processing is required to determine whether the current broadcast should be consumed or not, then things can get tricky.

I'm developing an app that can consume some (but not all) inbound SMS messages. For any given SMS message it will need to perform some analysis based on the sender's phone number and the message body (including database lookups) in order to determine if the message is one that is relevant to the app or not. In the vast majority of cases this will take less than 10 seconds, but it is possible that it could take longer on rare occasions.

To get around this I'm considering the following solution.

1. On receiving a broadcast for a received SMS, my receiver starts a background thread to perform the required analysis and handle the message if appropriate. 2. The main thread (currenly executing the onReceive() method) waits until either the background thread has finished its work, or 8 seconds have elapsed, whichever occurs first. 3. If the background thread finished within the allotted time (which should happen most of the time), then the main thread calls abortBroadcast() or not, (depending on the result of the analysis) and returns normally. 4. If the background thread did NOT finish within 8 seconds, then the main thread stops the background thread and instead starts a service to perform the work. In this case it does NOT call abortBroadcast(), and the broadcast will be passed to other receivers (eg the default messaging app) regardless of whether or not the service ends up handling the message. While not an ideal outcome, it is acceptable.

View 4 Replies View Related

Android :: Service And A BroadCastReceiver

Jun 2, 2010

I have seen several examples on how to implement a BroadCastReceiver, but how should I implement a Service who has to react on some pending Intent (for example incoming phone call)...Actually I was wondering about the same "prbolem" but in an Activity..You obviously have a class which extends a Service 9or an Activity) so it cannot also extend BroadCastReceiver...It looks like we cannot make "platform-awar" services and/or Activties ?

View 2 Replies View Related

Android :: Set BroadcastReceiver To Be Inactive

Jun 22, 2010

I have a BroadcastReceiver set up in my Android application that receives SMS receive events. This works fine, but I want to be able to toggle SMS receiving on and off by toggling the BroadcastReceiver on and off. Because if I have a simple boolean inside the onReceive method, even if the SMS receiving is off, my application will start.

View 1 Replies View Related

Android :: AlertDialog In BroadcastReceiver

Aug 8, 2010

I'm trying to create an application that can use the android as a fax machine, IE Send a picture as a fax or receive a fax and save as a picture. So far I'm starting from the ground up and making sure I can intercept a call at the users discretion. I have an Receiver registered in the Manifest of my program with a filter of Phone_State which flags when the state has changed(IE incoming call).

So on my BroadcastReceiver I'm trying to have an AlertDialog popup prompting the user to either accept as fax or call but the AlertDialog seems to throw a android.view.WindowManager$BadTokenException Error when it has an incoming call. My code is just simple an onReceive(context arg0, intent arg1) and I pass the arg0 to the AlertDialog...

The full error message is below


From what I have seen in the AlertDialog code, it passes the context as well as a Window and WindowManager, which I believe is why it's crashing, is there a better way or something else I should be using which might overlay the call screen?

View 2 Replies View Related

Android :: Can't Enable BroadcastReceiver

Jan 12, 2010

I got back to the widget development after upgrading to the latest SDK and all of the sudden my widget is failing on startup with this message:

ERROR/AndroidRuntime(5296): java.lang.RuntimeException:
Unable to start receiver topjob.widget.SearchWidget:
java.lang.SecurityException: Permission Denial:
attempt to change component state from pid=5296, uid=10057, package uid=10048

Here's two lines of code where exception occurs:..................

View 1 Replies View Related

Android :: BroadcastReceiver Crashing / Why Is So?

Feb 19, 2010

I have this Broadcast receiver registered code...

but when the line reaches context.startActivity(intentalarm);
the application crashes

may be it is where we pass first parameter to Intent, I'm not clear about.

View 1 Replies View Related

Android :: BroadcastReceiver Communicating With Activity

Feb 26, 2009

Is it possible to update a currently running activity from a BroadcastReceiver? I want to update my activity from a BroadcastReceiver that runs alongside it. When I run my app (from Eclipse), my activity starts. When the BroadcastReceiver is triggered, it currently tries to start the activity (with extras in the bundle...this is the important part), but nothing happens, presumably because the activity is already running. So my question is, how do I get the new information to my Activity (or even just tell the activity that there's new information to get if I stick the information in a database)? This seems like it should be fairly straightforward, but I'm clearly missing something.

View 3 Replies View Related

Android :: BroadcastReceiver Stopped Execution

Oct 13, 2009

My application used to start when phone start by broadcast reciever. After that i used to execute some code after every 10 seconds. Using handler but after some time it used to stop execution. Can some one tell me what can be reason behind it ?

View 2 Replies View Related

Android :: Stop BroadcastReceiver After Some Point

Nov 13, 2009

I want to stop BroadcastReceiver after some time / after some work.

How to stop BroadcastReceiver after some point from service/ activity ?

View 5 Replies View Related

Android :: Access Database In BroadcastReceiver?

Dec 12, 2009

I have a problem when using database in broadcastReceiver.

I can't open the database created in the activity. e.g: malwareDB = new PackageDB(this);

The eclipse give me the error that "PackageDB(this)" is undefined.

It seems that the BroadcastReceiver doesn't support the database?

Do have have to access the data base in the "service"?

Here is the definition of "PackageDB":


View 2 Replies View Related

Android :: Start Service From BroadcastReceiver

Jul 4, 2010

I am trying to start a service from the BroadcastReceiver, but I keep getting the startService line marked as an error:


View 2 Replies View Related

Android :: Don't Receive Intent - While Have A BroadcastReceiver

Sep 1, 2009

My current problem is that I don't receive an intent. I have a BroadcastReceiver and defined in the AndroidManifest.xml file that it also should receive intents with these actions.

View 2 Replies View Related

Android :: BroadcastReceiver Not Able To Receive Events

Jun 15, 2009

I have created a BroadcastReceiver to detect SDCard mount and unmount event, however, I am not able to receive any events at all: Code...

View 6 Replies View Related

Android :: BroadcastReceiver For Incoming Gmail

Nov 7, 2009

Does anybody know how to setup BroadcastReceiver's action and intent- filter so it can be invoked when Gmail is received?I thing CubeWorks does it, so it's not entirely impossible.Any help is welcome.

View 8 Replies View Related

Android :: SMS BroadcastReceiver Conflict With GPS LOCATION_SERVICE

Mar 1, 2009

SMS BroadcastReceiver conflict with GPS LOCATION_SERVICE.

Code is here:


View 2 Replies View Related

Android : How To Redirect BroadcastReceiver OnReceive?

Oct 13, 2010

What's the correct way (if any) to redirect a received Intent to another BroadcastReceiver? I have two BroadcastReceivers set to listen to the same intent. It works in development, but in production, only the first one registered in the manifest gets the intent. Can I call the other one's onReceive() method directly, passing the same context and intent? Is there a better way to pass the intent along once the first receiver is done with it?

View 1 Replies View Related

Android :: Passing Arguments To A BroadcastReceiver Through An Intent

Jan 14, 2010

I have an application, which sets an alarm using AlarmManager, which starts another Activity when it goes off. The AlarmManager takes a PendingIntent and spawns a BroadcastReceiver class when the specified time comes. I'm wondering whether there is any way that I can pass arguments to this BroadcastReceiver through the Intent object which goes into PendingIntent?I'd like to be able to retrieve arg1 in the BroadcastReceiver's onReceive(Context, Intent) method. I figured that the local variable my_intent would be the second parameter passed on to onReceive by the PendingIntent, but apparently that's not quite right. Is it possible to pass parameters between an Activity and a BroadcastReceiver in this fashion (using Intent.putExtra()) or should I use a ContentProvider instead?

View 3 Replies View Related

Android :: BroadcastReceiver To Listen For Activity Being Launched

Jun 22, 2010

I am wondering whether is possible to use a BroadcastReceiver to listen for an Activity being launched. I have no control of the Activity I need to know about as it is from the Android platform.

View 3 Replies View Related

Android :: BroadcastReceiver Never Getting Boot Completed Intent

Jan 12, 2010

I have a BroadcastReceiver which never enters onReceive(), so to debug I created a bare bones project with a simple BroadcastReceiver and still it never gets the BOOT_COMPLETED intent (see manifest below).

I do see a lot of warnings/errors in my Eclipse log (filtered and after manifest) which didn't seem to cause issues before, but maybe I have a bad install of the emulator? I have all the latest SDK and plugins. I also noticed that when I run the emulator I always get "Waiting for" popup for either Alarm or MMS.

The debugger attaches normally for my main Activity, it's just this "boot" receiver that never seems to start. I've tried using "com.boottest.BootReceiver" instead of".BootReceiver" to no avail.


View 4 Replies View Related

Android :: Calling Background Service From BroadcastReceiver

May 24, 2010

I am trying to call a push notification background service from BroadcastReceiver class, but my application crashes.When I call this service through an Activity it's working, but my goal is to call this service from a BroadcastReceiver.

View 2 Replies View Related

Android :: Access CallLog From A Service / Broadcastreceiver

Aug 17, 2009

Is there any way, to access the CallLog from a service or BroadcastReceiver?

View 2 Replies View Related

Android :: ACTION_USER_PRESENT BroadcastReceiver Not Be Registered In The Manifest?

Aug 30, 2010

I see that multiple broadcasts (ACTION_TIME_TICK, for example) cannot be registered in the manifest, the must be explicitly registered via Context.registerReceiver(). I am having trouble with the ACTION_USER_PRESENT broadcast intent. Specifically, I test on the emulator and my application keeps force closing with the error:


This is caused by


My manifest is fairly simple:


I am essentially attempting to create a Receiver that is awakened as soon as possible after my application is installed. The first time it is awakened, it registers a few listeners, and then it unregisters itself so it is never called again. (I really wish there was an intent fired immediately after your app had been installed, to allow a small bit of setup.

View 1 Replies View Related

Android :: BroadcastReceiver To Restart Killed - Crashed App?

Sep 14, 2010

I have an application and I would like to be able to restart it on the event of an error or a crash/app shutdown. I am familiar with how to register BroadcastReceivers, use alarms, etc.

Is there any signal I could intercept that the app sends out when it shuts down? Or that the OS sends out when any app shuts down?

View 2 Replies View Related

Android :: Call Main Activity From BroadcastReceiver?

Oct 28, 2010

While developing an alarm based application, i have stuck in a scenario.

When my alarm is fired, i can receive the event in BroadCastReceiver::onReceive().
Within this function, i want to notify/call a function, which is located on MainActivity.

How to achieve the same?

View 1 Replies View Related

Android :: Dataflow Between BroadcastReceiver ContentProvider And Activity?

Mar 19, 2009

I've developed an application that receives a Broadcast and then launches an Activity, where that Activity queries a ContentProvider which pulls information out of the DNS in real-time.

I'd like to be able to shuffle this so that instead of going:


It goes:


i.e. if the query() returns no data I want to miss out launching the activity, and allow the Broadcast message to fall through as normal.

If the query() does return data, I want that Cursor to be supplied to the Activity, so that I don't have to go and query for the data again.

In turn, the Activity has its own UI which the user needs to respond to.

View 2 Replies View Related

Android :: How To Unicast An Intent To An Activity With Inner BroadCastReceiver

Aug 18, 2010

I have 2 Activities that need to communicate with each other: ActivityA and ActivityB

Say that ActivityA opens ActivityB. How do I unicast a message from ActivityB to ActivityA without closing ActivityB?

Here's what I tried: setResult() - but the intent will be delivered only when ActivityB closes sendBroadcast() - but this sends the intent to everyone listening to the action.

I only want the action to reach ActivityA since it spawned ActivityB.

I tried having ActivityA registering a BroadCast receiver, but I cannot target that via Intent's SetComponentName(). startActivity() - this brings up ActivityA, which I don't want.

View 1 Replies View Related

Android :: Best Practice On Updating UI From BroadcastReceiver To A Certain Activity?

Jul 18, 2010

When i have a broadcastReceiver say android.intent.action.MEDIA_BUTTON and i want to update the current activity's UI without creating a new activity, is there any good practice on this one?

What i know (might not be correct)

1) I can put the BroadcastReceiver in the same class as the activity and call the updateUI function after certain activity

2) Create a ContentObserver?

3) Communicate to a service created by the activity, use aidl. (I dont know how to get the current service if its registered from an activity)

4) Create a custom filter on the broadcastReceiver located on the same class as the activity, and use context.sendBroadcast(msg of custom filter) and in the custom filter call updateUI (same as one but more generic?)

The final flow is it would come from a BroadcastReceiver and ends up updating the UI without renewing the activity (unless the activity is dead?)

Kindly provide links/source code on your how you tackle this kind of problem.

View 1 Replies View Related

Android :: Update Activity From BroadcastReceiver / Practice For It?

Mar 3, 2010

Does anyone know how I might go about accessing an Activity in an application from a BroadcastReceiver (in the same application)?

(I have some state information in the Activity I'd like to update)

I'm not sure if there is a best practice for it.

View 2 Replies View Related

Android :: Binding To A Local Service From A BroadcastReceiver

Sep 15, 2010

My application has the following components: 2 Activities A Service and a BroadcastReceiver

Whenever the user updates the system time, my broadcast receiver receives the Intent.ACTION_TIME_CHANGED. Now when this happens I want to reschedule a Handler in my Service. How do I bind to a Service within my BroadcastReceiver?

View 1 Replies View Related

Android : Inform Activity From A BroadcastReceiver ONLY If It Is In The Foreground

Feb 17, 2010

Maybe it's easy, but I couldn't really figure this out right so far... I got a BroadcastReceiver waiting to get triggered by the AlarmMangager - this works fine.

Now: because the event, if it occurs, needs to refresh some elements on screen of the main Activity, I would like to send an Intent from that background BroadcastReceiver to my Activity - but only if it is currently in the foreground, aka active.

If it is not running or not visible, I don't care - and the last thing I want to do is start the Activity by my intent! I handle repainting of the views in my onResume method, so I don't care at all.

EDIT: my BroadcastReceiver is waiting for alarms that must be notified to the user. So, it must be there and declared in the manifest. The problem is: it will have to decide whether the mentioned Activity is currently up in front or not.

View 3 Replies View Related

Android : Way To Access To Activity From BroadCastReceiver.onReceive?

Sep 7, 2010

I'm developing alarm application. I'm using listview on activity to reserve alarm. after application finish BroadcastReceiver.onReceive() method, I want to remove check of list. But i dont know how to access to activity.

View 1 Replies View Related

Android : How Can I Call Service Methods From BroadcastReceiver?

Dec 7, 2009

I made two applications. One for an activity receiving user input, the other for a background service. In the service package, I create two files (, StartSensorBroadReceiver will receiver an intent from activity application and call method inside of the service. There is no erron in the codes but I can not excute what is want. I meet a message like this "The application ServiceExample has stopped unexpectedly. Please try again." could you let me know. what is wrong? and how I can call service methods from broadcastReceiver?

View 5 Replies View Related

Android :: Sending And Receiving Data Messages Via A BroadcastReceiver

Feb 15, 2009

Is there already functionality similar to the push registry or wireless messaging API in J2ME implemented in Android? Or at least plans to do so?I have been looking at this issue for a while, because in a corporate environment it is essential to be able to push information out, or trigger actions via SMS or other connections.I have successfully sent an SMS between emulator instances, and successfully received an SMS by using a BroadcastReceiver on another emulator instance. I have also been able to use SmsManager. sendDataMessage to send a data message to a port on another emulator instance, but in this case the BroadcastReceiver is never triggered. This seems to be the closest the API's get to what I'm looking for.

View 3 Replies View Related

Android :: Difference Between Manifest And Programmatic Registering Of BroadcastReceiver

Sep 6, 2010

I am trying to understand the main differences between registering a BroadcastReceiver in the Manifest and registering it programmatically...

My understanding is basically as follows - would appreciate someone correcting my points if I am missing something.

Registered in Manifest:
- The OS will magically find and instantiate your class if needed, calling the onReceive() method, regardless what the running state of your application was
- Your receive will only get called once per broadcast (i.e. You can consider that registering in the manifest is like registering your 'class' for receiving the broadcast - and the broadcast instantiates your class as needed) (??)

Registered Programmatically:
- registering in code means that you are registering instances of your class to receive broadcast messages (i.e. if your code is a little sloppy, and you manage to register several times, you will end up with multiple BroadcastReceiver instances all having their onReceive() called for a broadcast
- to deregister, you need to deregister the specific BroadcastReceiver instance that you previously registered
- if your application gets destroyed by the OS, your onReceive() method will not be called for a broadcast

View 1 Replies View Related

Android :: Boot Completed BroadcastReceiver And AlarmManager Not Working

Jul 20, 2009

I am trying to create AlarmManager in BOOT_COMPLETED BroadcastReceiver.

It is NOT working, AlarmManager Receiver is never fired.



View 3 Replies View Related

Android :: Calling An InputMethod Method When A BroadcastReceiver Gets Called

Feb 19, 2010

I added a BroadCastReceiver to my application.I want to call my inputMethod's method but I can't find a way to access it's instance.but I couldn't find a way to get the the InputMethod instance from the InputMethodManager.Is doing a singleton the only way to access it?

View 1 Replies View Related

Android :: Pass Data From BroadcastReceiver Through To Activity Being Started?

Apr 11, 2010

I've got an Android application which needs to be woken up sporadically throughout the day.To do this, I'm using the AlarmManager to set up a PendingIntent and have this trigger a BroadcastReceiver. This BroadcastReceiver then starts an Activity to bring the UI to the foreground.All of the above seems to work, in that the Activity launches itself correctly; but I'd like the BroadcastReceiver to notify the Activity that it was started by the alarm (as opposed to being started by the user). To do this I'm trying, from the onReceive() method of the BroadcastReceiver to set a variable in the extras bundle of the intent,Can anyone tell me what's different about passing a bundle from a BroadcastReceiver to an Activity, as opposed to passing the bundle from an Activity to a BroadcastReceiver?

View 2 Replies View Related

Android :: BroadcastReceiver For Data SMS - Static Works - Dynamic Does Not

Mar 29, 2009

I have created a broadcast receiver statically by specifying it within the Manifest, and I have also created the "same" broadcast receiver in code and have registered it with the application context. The static way works very well, but the dynamic way does not receive the expected broadcast. It could be that I am not creating the intent filter correctly, or that I need to register it with some other context somewhere. Please see the code examples to see what I am doing. This is related to receiving data SMS, it works very well on a device using a broadcast receiver defined in the Manifest. The correct permissions are set for both examples.

The following is from the Manifest, and the resulting receiver gets the expected broadcasts:


The following is the code example that doesn't work (it does work with an intent like "android.provider.Telephony.SMS_RECEIVED" but not for data sms):


The question is - why does this broadcast receiver get notified of the incoming data messages? It seems some other resource is notified when the Manifest version of the receiver is created...

View 4 Replies View Related