2

i add android.intent.action.PACKAGE_FULLY_REMOVED as action and this my receiver

<receiver android:name=".MyBroadcastReceiver" android:enabled="true" android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_FULLY_REMOVED"/>
                <data android:scheme="package"/>
            </intent-filter>
        </receiver>

and my MyBroadcastReceiver here

public class MyBroadcastReceiver  extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {

        Toast.makeText(context,"app Removed",Toast.LENGTH_LONG).show();
        Log.e("MyBroadcastReceiver","app Removed");

    }
}

so i want to notify when app is removed from Device but is not working

Mahmoud Abu Alheja
  • 3,343
  • 2
  • 24
  • 41
  • Is this receiver in the package that is being removed? – StackOverthrow Jul 09 '18 at 22:25
  • yes must called when app removed @TKK – Mahmoud Abu Alheja Jul 09 '18 at 22:27
  • A receiver in a package that has been removed will obviously never be called. This event is for *other* apps to be notified when a package is removed, e.g., so a launcher can remove the icon. – StackOverthrow Jul 09 '18 at 22:33
  • oh thanks so this Receiver is not for removed my app ,, so what action i must add to know my app is go to removed ? – Mahmoud Abu Alheja Jul 09 '18 at 22:39
  • 1
    You can't. [There was a hack](https://stackoverflow.com/questions/11062780/how-to-start-an-activity-or-service-before-an-app-application-is-uninstalled-by) that could do this, but it was considered a security risk and Google was reportedly working to fix it back in 2012. – StackOverthrow Jul 09 '18 at 23:08

1 Answers1

1

You can't listen to android.intent.action.PACKAGE_FULLY_REMOVED/android.intent.action.PACKAGE_REMOVED on your all package because your own BroadcastReceiver is removed when your package is removed.

Liar
  • 1,235
  • 1
  • 9
  • 19