I am not able to receive the ACTION_TIME_CHANGED intent in my broadcast receiver class when I change the time from the phone. Is there anything in particular that I need to add in android.manifest?
I have already added
in broadcast receiver class:
else if((intent.getAction().equals(Intent.ACTION_TIME_CHANGED)) ||(intent.getAction().equals(Intent.ACTION_DATE_CHANGED ))){
Log.d("ContactsAppReceiver", "ACTION_TIME_CHANGED");
}
And in manifest.xml file. :
<action android:name="android.intent.action.ACTION_TIME_CHANGED"/>
Add to manifest:
<action android:name="android.intent.action.TIME_SET" />
Related
I am having problems with my Broadcast not being received.
I have tried using a standard broadcast and a localbroadcast and neither will work.
This is the broadcast code:
Intent intent = new Intent();
intent.setAction(WIFI_SKIPPED_INTENT);
context.sendBroadcast(intent);
where WIFI_SKIPPED_INTENT = "com.wefi.wifi.skip"
And this is in my manifest:
<receiver
android:name="com.wefi.receivers.WifiSkipReceiver"
android:exported="true"
android:enabled="true">
<intent-filter>
<action android:name="com.wefi.wifi.skip" />
</intent-filter>
</receiver>
I added log commands before the sending and they are showing but logs in the receiver are not.
This happens on Android 11, Android 10 and Android 8 phones.
Edit:
If we register dynamically fro the receiver within the code then it works great. It fails only when registering through the manifest.
As in title, broadcast receiver get called even no intent filter is specified in android manifest or in code. Even I specify concrete intent action in manifest like:
<receiver
android:icon="#drawable/ic_action_network_wifi_on"
android:name=".receivers.WifiReceiver">
<intent-filter>
<action android:name="android.intent.action.AIRPLANE_MODE"/>
</intent-filter>
</receiver>
The receiver get called when no airplane mode change.
Any ideas appreciated.
Hello I was trying to implement a custom Broadcast receiver for my Geofence app. I just went through the solution given here But I found that he is sending the broadcast from the receiver class which receives the same broadcast. can someone please tell me how this works. I have not worked much on custom broadcast.
He is sending the broadcast from one class and receiving it in another receiver. The line below is where he sends out the broadcast.
Intent intent = new Intent("com.aol.android.geofence.ACTION_RECEIVE_GEOFENCE");
Here is his manifest where he registers a receiver for that broadcast
<receiver android:name="com.aol.android.geofence.GeofenceReceiver"
android:exported="false">
<intent-filter >
<action android:name="com.aol.android.geofence.ACTION_RECEIVE_GEOFENCE"/>
</intent-filter>
</receiver>
you can send one Broadcast in another one with following code:
ntent local = new Intent();
local.setAction("BroadCastPath"); // like android.receiver.MyReceiver
context.sendBroadcast(local);
I have two intent actions in a single receiver class. In manifest file:
<receiver android:name=".ConnectivityReceiver" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"></action>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
And in receiver class inside onReceive():
#Override
public void onReceive(Context context, Intent intent) {
System.out.println("--------BOOT-----------"+intent.getAction());
}
Here intent.getAction() returns only "android.net.conn.CONNECTIVITY_CHANGE" but I am not able to track "Boot Completed" action. Is there anyway to get multiple intent actions from a common onReceive()?
Yes, you can get multiple broadcasts delivered to a single onReceive(). Make sure you have the permission
<uses-permission
android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
in your manifest.
Also, as of Android 3.1 you won't get the BOOT_COMPLETED broadcast unless your application has been run by the user at least once. See http://commonsware.com/blog/2011/07/13/boot-completed-regression-confirmed.html
I'm currently trying to catch states for ACTION_SCO_AUDIO_STATE_CHANGED as specified by:
http://developer.android.com/reference/android/media/AudioManager.html#ACTION_SCO_AUDIO_STATE_CHANGED
I have registered the intent on my manifest but I'm not getting anything when connecting to a bluetooth device. Any particular permission I need or something?
Manifest:
<receiver android:name="com.app.receiver.BluetoothReceiver">
<intent-filter>
<action android:name="android.media.SCO_AUDIO_STATE_CHANGED" />
<action android:name="android.bluetooth.device.action.ACL_CONNECTED" />
<action android:name="android.bluetooth.device.action.ACL_DISCONNECTED" />
<action android:name="android.bluetooth.device.action.ACL_DISCONNECT_REQUESTED" />
<action android:name="android.bluetooth.device.action.BOND_STATE_CHANGED" />
</intent-filter>
</receiver>
I can't get any of the calls from BOND_STATE_CHANGED, SCO_AUDIO_STATE_CHANGED or ACL_DISCONNECT_REQUESTED. The other intents I'm receiving them just fine.
Thanks,
-Jona
It's probably a broadcast intent that cannot be received using the Manifest. You'll have to setup a BroadcastReceiver object and register it to receive the broadcast. The Receiver must be active in order to receive the intent.
Some broadcasts intents work like this while others are allowed to be caught via the manifest.
The other possibility is that the receiver requires a permission that you aren't requesting.
This is an important note from the SDK about Context.registerReceiver().
Note: this method cannot be called from a BroadcastReceiver component; that is, from a BroadcastReceiver that is declared in an application's manifest. It is okay, however, to call this method from another BroadcastReceiver that has itself been registered at run time with registerReceiver(BroadcastReceiver, IntentFilter), since the lifetime of such a registered BroadcastReceiver is tied to the object that registered it
<uses-permission android:name="android.permission.BROADCAST_STICKY"