title: Android application uninstall listner
body: <p>I WANT to make an application in which i want to receive a signal or anything else if user try to uninstall my application
  is there any way to do that ?
  Please help</p>
  
  <p>Here is my manifest of my demo application</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.uninstalldefence"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk
          android:minSdkVersion="8"
          android:targetSdkVersion="18" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;activity
              android:name="com.example.uninstalldefence.MainActivity"
              android:label="@string/app_name" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
          &lt;receiver
              android:name="com.example.uninstalldefence.BootReceiver"
              android:label="Bilal" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.PACKAGE_ADDED" /&gt;
                  &lt;action android:name="android.intent.action.PACKAGE_REMOVED" /&gt;
  
                  &lt;data android:scheme="Package" /&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
      &lt;/application&gt;
  
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="android.permission.RESTART_PACKAGES" /&gt;
  
      &lt;Uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>and here is my broadcast receiver. But it didn't work
  Can you please provide any help ?
      package com.example.uninstalldefence;</p>
  
  <pre><code>import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
  import android.telephony.SmsManager;
  import android.widget.Toast;
  
  public class BootReceiver extends BroadcastReceiver {
  
      @Override
      public void onReceive(Context context, Intent intent) {
          // Receive install the radio
          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(context.getApplicationContext(), "Added!",
                      Toast.LENGTH_LONG).show();
  
          }
          // Receive uninstall broadcast
          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(context.getApplicationContext(), "Removed!",
                      Toast.LENGTH_LONG).show();
  
  
          }
      }
  }
  </code></pre>