不要在使用on receive()方法卸载应用程序时收到通知



在ApplicationBroadcastService.class文件中挖掘代码为:

public class ApplicationBroadcastService extends BroadcastReceiver{
@Override   
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Activity a=new Activity();
Toast.makeText(context, " Uninstall  ", Toast.LENGTH_LONG).show();
ContentValues values = new ContentValues();         
values.put(ContactsContract.Groups._ID, 4444);
a.getContentResolver().delete(ContactsContract.Groups.CONTENT_URI,
values.toString(),null)
}
}

,在menifest.xml代码中是:

<receiver android:name=".ApplicationBroadcastService">
    <intent-filter>
            <category android:name="android.intent.category.DEFAULT" />
            <action android:name="android.intent.action.PACKAGE_ADDED"  />
            <action android:name="android.intent.action.PACKAGE_CHANGED" />
            <action android:name="android.intent.action.PACKAGE_INSTALL" />
            <action android:name="android.intent.action.PACKAGE_REMOVED" />
            <action android:name="android.intent.action.PACKAGE_REPLACED" />
            <data android:scheme="package" />
    </intent-filter>
</receiver>

但是当我卸载应用程序时,我没有收到任何通知。实际上,我想删除联系人组是在安装时在接收通知中创建的。对此有什么建议吗?

我也对这件事做了研究,最后得出结论,没有办法在应用程序中获得卸载特定应用程序的事件。这是一个安全原因,android不提供。但是你可以在其他没有安装的应用程序中得到一些事件。

最新更新