I have a broad cast receiver for my application which listens uninstalling a package, and then it will start a transparent activity as requirement. (My application itself have an option to uninstall a package that is related to my other application only) I registered my receiver in manifest as follows.
<receiver android:name=".PackageRemoveReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
<data android:scheme="package"/>
</intent-filter>
</receiver>
My receiver class is as follows.
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
this.context = context;
boolean replacing = intent.getBooleanExtra(Intent.EXTRA_DATA_REMOVED, false);
Log.d("Log","getting receivers");
if(replacing){
......
......
startActivity(context);
}
private void startActivity(Context context) {
// TODO Auto-generated method stub
Intent i = new Intent(context, TransparentActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
so, after listening the intent it is opening my activity. Up to here it is working fine.
But, whenever am doing something like uninstalling different applications (other than my applications ) from settings, it always listening and opens my transparent activity.
I want to run broad cast only , whenever a particular package removed. Is it possible, if yes how to do it?
Check for the package name in
onReceive():