1

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

Here is my manifest of my demo application

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.uninstalldefence"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.uninstalldefence.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <receiver
            android:name="com.example.uninstalldefence.BootReceiver"
            android:label="Bilal" >
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_ADDED" />
                <action android:name="android.intent.action.PACKAGE_REMOVED" />

                <data android:scheme="Package" />
            </intent-filter>
        </receiver>
    </application>

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.RESTART_PACKAGES" />

    <Uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

</manifest>

and here is my broadcast receiver. But it didn't work Can you please provide any help ? package com.example.uninstalldefence;

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();


        }
    }
}
user3765485
  • 69
  • 2
  • 9
  • possible duplicate of [Android:Listen to own application uninstall event](http://stackoverflow.com/questions/19475765/androidlisten-to-own-application-uninstall-event) – Henry Jul 09 '14 at 18:00

1 Answers1

1

Is it possible to detect Android app uninstall?

Here is an post. I dont know your exact application but you could have the user broadcast a unique id everytime they start the app. This way you could gather how many 'active' users you have rather than how people have your app installed.


1) It is not possible to run code before your app is installed as stated in the documents.

Broadcast Action: An existing application package has been removed from the device. The data contains the name of the package. The package that is being installed does not receive this Intent. http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_REMOVED

Community
  • 1
  • 1
toidiu
  • 965
  • 2
  • 12
  • 25
  • Hey i have added my code please check if you help me ? – user3765485 Jul 09 '14 at 18:33
  • Your code will can only detect when other apps are being uninstalled. So the work around I suggested is to keep track of how many 'active' users you have on the server side. _You can define active as: users who have used you app within the last week._ – toidiu Jul 10 '14 at 18:06