Android :: Receiver Not Receiving Broadcasts From Another App?
Jul 5, 2010App A has this Broadcast Receiver in its manifest (within <application>): Code...
View 1 RepliesApp A has this Broadcast Receiver in its manifest (within <application>): Code...
View 1 RepliesI am trying to get the intent "android.intent.action.BOOT_COMPLETED" sent only to the receiver "com.android.mms.transaction.MmsSystemEventReceiver" as this triggers the sms notification to be updated and removed if there is no longer any unread sms's. The issue I have is I need to make sure the broadcast is only sent to the class above. If it goes to other receivers the phone could end up in an unknown state or something strange. The code below does not seem to work.
Intent intent = new Intent(); intent.setAction("android.intent.action.BOOT_COMPLETED");
intent.setClassName("com.android.mms", ".transaction.MmsSystemEventReceiver");
activity.sendBroadcast(intent);
This code does work but since it goes to all receivers I have noticed some errors starting to show up in logs etc.
Intent intent = new Intent();
intent.setAction("android.intent.action.BOOT_COMPLETED");
activity.sendBroadcast(intent);
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)
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...
I am attempting to listen for system fired Intents, specifically regarding text input, using a class extending BroadcastReceiver. I see there is an Intent called ACTION_INPUT_METHOD_CHANGED (android.intent.action.INPUT_METHOD_CHANGED) which I hope to be able to use to know when the keyboard or text input is attempted by the user. (I assume this intent will work as I can use an InputMethodManager object to handle keyboard related tasks)
My java code:
package com.BroadcastReception;
import android.content.BroadcastReceiver; import android.content.Context;
import android.content.Intent; import android.util.Log;
public class InputMethodChangedReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context arg0, Intent arg1) {
// TODO Auto-generated method stub
if (arg1.getAction().equals("android.intent.action.INPUT_METHOD_CHANGED")) {
Log.d(this.toString(), "Event Fired");} } }
I want to know whenever someone is called, calls, smsed or smses. I figured for the calls I'd use the phone state change to trigger when I should check the CallLog provider again. I couldn't see any direct way of getting broadcasts from the CallLog. Did I miss it?
For SMSes I'm having more trouble. I'd like to know whenever and SMS is sent or received. Being able to receive STATUS_ON_SIM_READ and STATUS_ON_SIM_SENT would be great, but from what I've read in the Sms Manager that would depend on the sending application. I can't seem to find any evidence of a default one that android places when it sends. I also couldn't find an sms log provider or anything similar.
How can I catch SCREEN_ON/SCREEN_OFF broadcasts? I have tried for hours, but failed.
View 10 Replies View RelatedI have started developing a tool, which should react on an outgoing call or sms and also to be started at boot time. The start at boot time does work properly, but I'm not able to receive the broadcasts for the outgoing calls.
Who can tell me, what is wrong with my code? For this, I added two receivers in my manifest and implemented the broadcast receivers:
manifest.xml: <receiver android:enabled="true" android:name=".BootUpReceiver"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" /> </intent-filter> </receiver>
<receiver android:name=".TelephoneViewer" android:enabled="true" android:exported="true"
android:permission=""> <intent-filter> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
<action android:name="android.intent.action.PHONE_STATE" />
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter> </receiver>
TelephoneViewer.java: public class TelephoneViewer extends BroadcastReceiver {
@Override public void onReceive(Context context, Intent intent) {
Log.d(this.getClass().getSimpleName(), "Telephoneviewer.onReceive()");
Toast.makeText(context,"TelephoneViewer.onReceive()", Toast.LENGTH_SHORT).show(); }
I have two applications, one of which (B) implements a broadcast receiver. The application (A) which sends the broadcast, binds a permission to it which the receiver (B) shall possess. The problem is now: If I install the receiver (B) first and the sender (A) afterwards, the receiver will never receive the broadcast. I assume this happens because the installation of the receiver somewhere fails when it comes to the "uses permission" part of the manifest (because this permission is not yet registered/defined).
However, this issue should be resolved as soon as the sender (which defines the permission in the manifest) is installed, but unfortunately isn't. It does not even help to re-install the receiver. The only way to resolve the issue is to completely uninstall the receiver application and do a fresh install. Is this behaviour intended ("not a bug, a feature")?
Does the Alarm Clock broadcast any intents? I would like to be able to have my application automatically launch after a person's alarm clock goes off, and they press "dismiss" (rather than "sleep"). I assume that would require a receiver looking for a broadcast of some kind.
View 2 Replies View RelatedI am trying to register a Broadcast Receiver to receive broadcast events for the package events. Following is the code and my receiver in the manifest file. The log statment never happens, but I can clearly see the same broadcast firing for "HomeLoaders" (the Launcher) debug statements.
public class IntentListener extends BroadcastReceiver {
@Override public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Log.i("INTENT LISTNER:", intent.getAction()); } }
<receiver android:name="IntentListener" android:enabled="true" android:exported="true">
<intent-filter> <data android:scheme="package"></data>
<action android:name="android.intent.action.PACKAGE_ADDED"></action>
<action android:name="android.intent.action.PACKAGE_ADDED"></action>
<action android:name="android.intent.action.PACKAGE_CHANGED"></action>
</intent-filter> </receiver>
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 RelatedI have the following broadcast receiver:
public class MyRingModeReceiver extends BroadcastReceiver {
@Override public void onReceive(Context context, Intent intent) {
Logger.iLog("In my Receiver"); } }
I then have a service that onCreate does the following:
IntentFilter filter = new IntentFilter();
filter.addAction("android.media.RINGER_MODE_CHANGED");
registerReceiver(new MyRingModeReceiver() , filter);
When I place a call to the emulator and use the volume keys to modify (silence) the ringer
nothing happens.
We are designing a system with a PC base station and 100 Android mobiles communicating over WiFi. They will use XLM-RPC as the method of mobile to base station communication. However, sometimes the base station needs to broadcast a message to all mobiles. Should we use "http server push" for this, i.e., have the base station leave the connections open to all the mobiles? Is there a better way? Publish-subscribe is possible, but doesn't seem mature on Android yet.
View 1 Replies View RelatedI have custom view and once some action occur in it (say touch/key event) I'd like to call some code in my activity. My question is if broadcasts (intent filters/broadcast receivers) are good communication mechanism for such thing? If not, what is normal/android preferred way to do it?
View 5 Replies View RelatedI have two BroadcastReceiver registered. When the app is closed they both fire at the appropriate times and do the appropriate things. If the app is closed then killed (say with an AppKiller), the receivers never receive their broadcasts, and nothing happens. Presumably the same thing happens if the parent app is killed due to low memory, so how do I ensure those broadcasts are fired/received. The API states that even if the app is killed it should fire, does anyone else have experience with this situation? If it helps my manifest is:
<!-- receivers for AlarmManager -->
<receiver android:exported="true" android:label="Shift roster updating calendar."
android:name="com.skooter.shiftroster.backend.service.UpdateCalendar" >
</receiver> <receiver android:exported="true" android:label="Shift roster checking alarm."
android:name="com.skooter.shiftroster.backend.service.SetWakeup" >
</receiver>
and nothing esoteric is going on in the AlarmManager/BroadcastReceivers
How much accurate are the coordinates received by the GPS antenna in the reality?I'm using the emulator but it doesn't work well with coordinates too much close is there nobody that have tested an application based on the package "Location" in a real device(I don't have a real one yet..) and knows how to answer me?
View 7 Replies View RelatedCan Android use Bluetooth GPS Receivers in its various applications, such as MyTracks, CardioTrainer, Google Maps etc, is there an app I can install to allow this, or does the functionality have to be supported by the relevent software application (MyTracks, GoogleMaps etc) itself.If the latter, are there any navigation programs I can install which support this?
View 1 Replies View RelatedHi we get an event when new sms come in android but can we get any event when user send a messages, in short is there any receiver to track sending sms as we track incoming sms.
View 1 Replies View RelatedI'm trying to write a simple application that attempts to receive SMS messages and handle them. I've followed several tutorials but I'm getting nowhere, when I send a SMS to the emulator, the Intent never seems to get fired.I'd really appreciate some guidance with what's going wrong. I'm just getting into Android development but I think I have my head wrapped around (most of) it. While monitoring the emulator's logcat, the log events never come up, and debugging breakpoints are never hit, so I have a feeling it's somewhere in my intent filter.
View 4 Replies View RelatedI am having an inner class which extends BroadcastReceiver.But I am getting error Unable to instantiate receiver org.example.test.OuterClass$InnerClass.
View 2 Replies View RelatedI have found the solution to this problem, the issue was I was also supposed to add the data tag:<data android:mimeType="application/vnd.wap.mms-message" />.Can someone provide some sample code to access the contents of the MMS message received.
View 2 Replies View RelatedI 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 RelatedA 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 RelatedI 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 RelatedAny experts on AlarmManager out there?I've got something weird going on.The basic code to set my repeating alarm works fine. I can close my app and the alarm will continue to run like clockwork every five minutes. It works fine only if I set it in the app and then close the app.I've got a registered BootReceiver for re-registering the repeating alarm. I know it fires on boot b/c the log message clearly shows it is firing and re-setting the repeating alarm in question for the same frequency. But the AlarmManager is not firing.Basically, the nearly identical code for setRepeating() fires when set from the app and continues to run when the app is closed, so I know my AlarmReceiver is functioning, but the AlarmManager is either not broadcasting this alarm or my receiver doesn't work from an alarm set in the boot receiver.
View 9 Replies View Relatedi figured out how to listen for outgoing calls. however, i can't find any docs or code samples for making a Receiver that catches outgoing sms or email.
View 10 Replies View RelatedI 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?
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 RelatedI 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?