broadcast receiver for app uninstall without activity that always run
<p>i am trying detect app uninstall using broadcast receiver.</p>

<p>i managed my app that creating a receiver without activity for </p>

<p>app uninstall.when i run my for the first time and go to the</p>

<p>Applications->manage application->uninstall it works for first time for only one </p>

<p>app but it doesn't receive any response after that</p>

<p>my receiver is shown to you</p>

<p>public class AppReceiver extends BroadcastReceiver {</p>

<pre><code>@Override
public void onReceive(Context ctx, Intent intent) {

    // TODO Auto-generated method stub
 if(intent.getAction().equals(Intent.ACTION_PACKAGE_REMOVED))

 {
    Intent i=new Intent(ctx.getApplicationContext(),AppUninstall.class);

    ctx.startService(i);
}
}
</code></pre>

<p>}</p>

<p>i've added the action in manifest file for the  receiver like this</p>

<p>

<pre><code>android:versionCode="1"

android:versionName="1.0" &gt;

&lt;uses-sdk android:minSdkVersion="8" /&gt;

&lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;

&lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/&gt;

   &lt;application

    android:icon="@drawable/ic_launcher"

    android:label="@string/app_name" &gt;

    &lt;receiver android:name="r.c.a.AppReceiver" android:enabled="true"&gt;

        &lt;intent-filter&gt;

            &lt;action android:name="android.intent.action.PACKAGE_REMOVED" /&gt;

            &lt;data android:scheme="package" /&gt;

            &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;

        &lt;/intent-filter&gt;

    &lt;/receiver&gt;

    &lt;service  android:name="r.c.a.AppUninstall" android:enabled="true"&gt;&lt;/service&gt;

&lt;/application&gt;
</code></pre>

<p></p>

<p>and from the receiver class i start a service </p>

<p>ublic class AppUninstall extends Service {</p>

<pre><code>private final IBinder mBinder = new LocalBinder();

    String pack;

    NotificationManager nfm;

    Notification nf;
@Override
public IBinder onBind(Intent arg0) {

    // TODO Auto-generated method stub

    return mBinder;
}
@Override
public void onCreate() {


        }
@Override                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
public void onDestroy() {

}
public int onStartCommand(Intent intent, int flags, int startId) {

// TODO Launch a background thread to do processing.

    super.onStartCommand(intent, flags, startId);


    pack=intent.getPackage();

    nfm=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);

            int NOTIFICATION_ID = 1;

           Intent intent1 = new Intent();

          PendingIntent pi = PendingIntent.getActivity(AppUninstall.this, 1, intent1, 0);

          nf=new Notification(R.drawable.ic_launcher,"App                            Uninstalled",System.currentTimeMillis());

      nf.setLatestEventInfo(getApplicationContext(), pack, null, pi);



          startForeground( NOTIFICATION_ID,nf);

       return Service.START_STICKY;


    }

 public class LocalBinder extends Binder {

       AppUninstall getService() {

            return AppUninstall.this;
        }

}
</code></pre>

<p>}</p>

<p>please any one help me thanks in advance</p>
