1

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.

Nirav
  • 5,700
  • 4
  • 34
  • 44
  • 1
    possible duplicate of [Receiving package install and uninstall events](http://stackoverflow.com/questions/7470314/receiving-package-install-and-uninstall-events) – Reno Nov 22 '11 at 13:30

2 Answers2

2

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 the PACKAGE_REMOVED action). See this link here.

Community
  • 1
  • 1
Huang
  • 4,812
  • 3
  • 21
  • 20
-1

You need to add android.permission.BROADCAST_PACKAGE_REMOVED into AndroidManifest.xml

Raghav Sood
  • 81,899
  • 22
  • 187
  • 195