I am using below code to get uninstall package broadcast receiver but I don’t get any response. can any one say what’s wrong with code.
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pack.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".TestprojectActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="UninstallApk">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
<action android:name="android.intent.action.ACTION_POWER_CONNECTED"/>
</intent-filter>
</receiver>
</application>
</manifest>
UninstallApk.java
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;
public class UninstallApk extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.i("DATA", "Apk uninstall");
Toast.makeText(context,"APK uninstall",Toast.LENGTH_LONG).show();
}
}
When I plug in charger it shows me Toast but when I uninstall any other application form Application->manage Application it doesn’t show any response.
Thank You.
Please search the questions on SO first, and you may get the answer you want because someone else has asked that.
In your case, you have to set the dataSchema for the
BroadcastReceiver. I have answered such a problem (it also works for thePACKAGE_REMOVEDaction). See this link here.