Reputation: 1311
I am developing an app which needs a broadcast when app opens every time. I had registered the receiver in manifest like this.
<receiver android:name="package.broadcast.example" >
<intent-filter>
<action android:name="android.intent.action.PACKAGE_RESTARTED" />
<data android:scheme="package"/>
</intent-filter>
</receiver>
But i cant able to receive the broadcast. I spent 3 hours on this still i cant find wats the mistake. Can anyone refer me the working example of this broadcast. Thanks.
Upvotes: 2
Views: 3469
Reputation: 3412
Restarted Application/Package does not receive broadcast...
check the following link for details you can check this link
http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_RESTARTED
Upvotes: 2
Reputation: 3412
do u have the following code which extends BroadcastReceiver, if not than try the following code:
public class AutoConnection extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if ((intent.getAction() != null)
&& (intent.getAction()
.equals("android.intent.action.PACKAGE_RESTARTED"))) {
Toast.makeText(context, "Pacakge Restarted",
Toast.LENGTH_LONG).show();
}
}
}
and in android manifest file add the following code:
<receiver android:name=".AutoConnection" >
<intent-filter>
<action android:name="android.intent.action.PACKAGE_RESTARTED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
Upvotes: 0