简体   繁体   English

我正在制作一个应用程序,想知道何时卸载该应用程序

[英]I am making an app and want to know when the app is uninstalling

I am making an app and want to know when the app is uninstalling. 我正在制作一个应用程序,想知道何时卸载该应用程序。 For doing it, I used BroadcastReceiver but I don't know where is my code is wrong? 为此,我使用了BroadcastReceiver,但是我不知道我的代码在哪里错误? (when my app is uninstalling, BroadcastReceiver can't receive any message about uninstalling) It's my app's Manifest: (当我的应用程序正在卸载时,BroadcastReceiver不会收到任何有关卸载的消息)这是我的应用程序的清单:

<receiver android:name="receiver">
  <intent-filter>
     <action android:name="android.intent.action.PACKAGE_ADDED"/>
     <action android:name="android.intent.action.PACKAGE_DATA_CLEARED"/>
     <action android:name="android.intent.action.PACKAGE_INSTALL"/>
     <action android:name="android.intent.action.UID_REMOVED"/>    
     <action android:name="android.intent.action.PACKAGE_REMOVED"/>
     <action android:name="android.intent.action.MEDIA_REMOVED"/>
     <action android:name="android.intent.action.MEDIA_BAD_REMOVAL"/>  
     <action android:name="android.intent.action.BATTERY_OKAY"/>         
     <data android:scheme="com.example.testpermission"/>
  </intent-filter>

You cannot get an event when your own app is uninstalling. 卸载自己的应用程序时,您不会收到事件。 See here . 这里 There is also a post on the subject here . 也有关于该主题的帖子在这里

You can't, but if you have second installed application on the device - you can get notification via that application about the uninstallation of the first one (as far as I remember). 您不能,但是如果您在设备上安装了第二个应用程序,则可以通过该应用程序收到有关第一个应用程序卸载的通知(据我所记得)。

I believe that the application cannot monitor its own uninstall from two reasons: 我认为该应用程序无法监视其自身的卸载有两个原因:

  1. It will make it much harder to uninstall application (some evil apps might even try to do something bad when their application is being removed). 这将使卸载应用程序变得更加困难(某些恶意应用程序甚至在删除其应用程序时甚至可能尝试做一些不好的事情)。
  2. If you remove application - you cannot run it, or send it events! 如果删除应用程序-您将无法运行它或发送事件! The app should be closed for clean deletion. 该应用程序应关闭以彻底删除。

About how to do it from second app: Your second app should be a receiver to the ACTION_PACKAGE_REMOVED event (read about BroadcastReceiver, and see: http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_REMOVED ) 关于如何从第二个应用程序执行操作:您的第二个应用程序应该是ACTION_PACKAGE_REMOVED事件的接收者(有关BroadcastReceiver的信息,请参阅: http : //developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_REMOVED

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 卸载应用程序时调用网络服务 - Calling webservice when uninstalling app 我正在实施一个应用程序并提高尺寸竞争力 - I am implementing an app and making Size competibility 我正在制作一个壁纸应用程序。 我被困在某个地方 - I am making an wallpaper app. And I am stuck somewhere 卸载应用程序时删除邻近警报 - Remove proximity alerts when uninstalling app 卸载应用程序时 SQLite 不会擦除 - SQLite does not erase when uninstalling app 卸载应用程序时清除应用程序文件和文件夹 - Application Files and Folders cleanup when Uninstalling the App 卸载应用程序时,“以下应用程序是另一个应用程序的一部分”警报 - 'The following app is part of another app' alert when uninstalling an app 我正在制作一个 Android 应用程序,当我构建并运行它时,应用程序停止并显示以下错误,我该怎么办? - I am making one Android App and when I build it and run, the app stops and shows following error so what can I do? 当我在浏览器中并单击链接时,我想在操作列表中查看我的应用程序,然后使用我的应用程序转到该链接 - When I am in a browser and I click on a link I want see my app in an action list and I go to the link using my app 我希望我的Android应用程序知道何时启动了另一个应用程序 - I want my Android app to know when another application has been started
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM