如何知道我的应用程序从设备上卸载......?我的、应用程序、设备

2023-09-12 07:45:57 作者:看破

我已经安装在许多设备的应用程序。

I have an app installed in many devices.

如果应用程序是从任何设备的卸载,我需要的指示。

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

如何实现这一目标。

在此先感谢...!

推荐答案

我的建议会是以下。您可以拦截的意图您的应用程序卸载。简单的说下code在你的manifest文件:

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.