Reputation: 105
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()
?
Upvotes: 0
Views: 1074
Reputation: 95578
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
Upvotes: 1