I want to get notification whenever application is going to be uninstall, I have googled but I have used this method in BroadCastReceiver class
public void onReceive(Context ctx, Intent intent) {
Uri data = intent.getData();
Log.d("TAG", "Action: " + intent.getAction());
Log.d("TAG", "The DATA: " + data);
if (intent.getAction (). equals ("android.intent.action.PACKAGE_ADDED")) {
String packageName = intent.getDataString ();
System.out.println ("installed:" + packageName + "package name of the program");
Toast.makeText(ctx, "installed:" + packageName + "package name of the program", Toast.LENGTH_LONG).show();
}
if (intent.getAction (). equals ("android.intent.action.PACKAGE_REMOVED")) {
String packageName = intent.getDataString ();
System.out.println ("uninstall:" + packageName + "package name of the program");
Toast.makeText(ctx, "uninstall:" + packageName + "package name of the program", Toast.LENGTH_LONG).show();
}
}
and adding in Android Manifest class
<receiver android:name="PackageChangeReceiver" >
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<data android:scheme="package" />
</intent-filter>
</receiver>
But When I install application then it shows message but when we uninstalled application then it doesn't show message. Someone is suggesting to use rooting for it but I am confused I don't have idea of how to make root device programmatically ?
My Question is:- 1. How to show message whenever we uninstall the application from device ? 2. If it is possible without using rooting device please guide me or provide some method or code. 3. If rooting device is only possible way then please help me how to implement it ?
Thanks in advance