How to know my app is uninstalled from the device...?

11,290

Solution 1

My proposal will be the following. You can intercept the intent for your application uninstall. Simply put the following code in your manifest file:

<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.DELETE_PACKAGES" />
<uses-permission android:name="android.permission.CLEAR_APP_CACHE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".UninstallIntentActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <action android:name="android.intent.action.DELETE" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="package" android:pathPattern="com.testpack.yourapp" />
        </intent-filter>



    </activity>

</application>

After this you can somehow process that your application is going to be deleted (for instance, send you a email), and call the package manager uninstaller.

Solution 2

You cannot tell when someone uninstalls your app unless you keep track on the statistics in android market. And unless you have only a few installs, that may prove difficult

Share:
11,290
Noby
Author by

Noby

Android apps developer.

Updated on June 27, 2022

Comments

  • Noby
    Noby about 2 years

    I have an app installed in many devices.

    If app is uninstalled from any of the device I need an indication.

    How to achieve this.

    Thanks in advance...!

  • mseo
    mseo over 12 years
    Then there's no way to do it.
  • Noby
    Noby over 12 years
    I am in search of programmatic approach for the same task.
  • Bill Gary
    Bill Gary over 12 years
    you CANNOT know when a device uninstalls your app programatically lol
  • Noby
    Noby over 12 years
    Do I need in add this into my app...?
  • Noby
    Noby over 12 years
    My main activity is different. If I place this code my launcher activity will not launch when app started...!
  • Yury
    Yury over 12 years
    Yep, of coarse you should modify the code. Here I've showed just permissions that you need and intent-filter.
  • Kishore
    Kishore over 11 years
    its not lol..!! It is done already by McAfee, NQ and many others.
  • Seshu Vinay
    Seshu Vinay over 9 years
    @BillGary its also done by UC Browser. It opens a webpage when app is uninstalled. I don't know what made you lol.
  • Vivek Elangovan
    Vivek Elangovan about 9 years
    Hi @Yury I want to send a mail to specific mail id wen user click on uninstall button.. Can u pls help me out..
  • Sam
    Sam about 7 years
    I just tested this in Android 7.1.1 and it didn't work.
  • portfoliobuilder
    portfoliobuilder over 3 years
    These permissions are only granted to system apps