[英]Uninstall App from device
我想從設備中刪除應用程序,因為我執行卸載,所以必須從ArrayList中刪除應用程序,並像明智地更新應用程序抽屜。
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_PACKAGE_ADDED);
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
filter.addDataScheme("package");
registerReceiver(new RefreshApps(), filter);
}
public class RefreshApps extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Toast.makeText(context, "App Installed/Removed" ,Toast.LENGTH_SHORT).show();
}
}
您可以發現某個應用正在通過BroadcastReceiver監聽ACTION_PACKAGE_REMOVED刪除。 您可以通過聽ACTION_PACKAGE_ADDED來發現已經安裝了一個。 顯然,這些功能適用於您自己的應用以外的任何應用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.