安卓:听自己的应用程序卸载事件 [英] Android:Listen to own application uninstall event

查看:278
本文介绍了安卓:听自己的应用程序卸载事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按我的RND和执行应用程序无法获得意图为themselves.Is是这样的吗?<一卸载href="http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_FULLY_REMOVED">Fully删除和

<一个href="http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_REMOVED">Removed必须要做些什么吗?

如何海豚浏览器的家伙能够做到<一个href="http://stackoverflow.com/questions/18440293/how-does-dolpin-web-browser-get-notified-when-its-being-uninstalled">receive取出事件,并开始浏览器所附图片

他们是有一定的轮询机制来检测?

输入会一定会非常非常AP preciated。

  ADB:
        一十二月10日至20号:37:00.997:D / BackupManagerService(527):接收到的广播意向{行为= android.intent.action.PACKAGE_REMOVED DAT =包:mobi.mgeek.TunnyBrowser FLG = 0x8000010(有群众演员)}
    一十二月10日至20号:37:00.997:V / BackupManagerService(527):removePackageParticipantsLocked:UID = 10112#1
    一十二月10日至20号:37:01.007:D / dalvikvm(527):GC_EXPLICIT释放2247K,免费12%20128K / 22868K,暂停3毫秒+ 10毫秒,总212ms
    一十二月10日至20号:37:01.107:D / dalvikvm(527):GC_FOR_ALLOC释放1508K,15%的自由19649K / 22868K,暂停60毫秒,总60ms的
    一十二月10日至20号:37:01.137:D / AndroidRuntime(4028):调用主入口com.android.commands.am.Am
    一十二月10日至20号:37:01.137:D / dalvikvm(4028):注:类Landroid / APP / ActivityManagerNative;拥有163未实现(抽象)方法
    一十二月10日至20号:37:01.147:I / ActivityManager(527):开始U0 {行动= android.intent.action.VIEW dat=http://survey.dolphin.com/int/uninstall?id=014f4d1981d6f88bb56630e7a3a7550a&pn=mobi.mgeek.TunnyBrowser&v=248&s=ofw&it=1382250136565&ut=1382250127000&m=Nexus 4&os=android&osv=4.3&cc=US&no=40471&lang=en&jk=uninstalled&ft=212&ht=957&ct=0&nt=1&res=768*1184&ifi=1&lts=1&iow=0&iom=0&iospd=0&iogs=0&debug=false&t=1382252820000 FLG = 0x10000000处CMP = com.android.chrome /从PID 4028 com.google.android.apps.chrome.Main}
    一十二月10日至20号:37:01.157:D / AndroidRuntime(4028):关闭虚拟机
 

解决方案

下面是一种方法,你可以得到你自己的应用程序的卸载事件。

在本地code用的inotify 。 例如:可以使用 inotify_add_watch 来监视应用程序的数据缓存文件夹,如: /数据/数据​​/你的包名/缓存
当应用程序被卸载,就可以得到该文件夹​​的删除事件。

另外一个关键点是,的inotify 应该从自己的应用程序一个单独的进程中运行。
您可以调用叉()做到这一点。

我已经验证的逻辑。 :)

As per my RnD and implementation apps can't get intents for the uninstallation of themselves.Is it that so?.Fully Removed and

Removed is something to do here?

How dolphin browser guys able to do so receive removed event and start browser as in the attached image

Are they have some polling mechanism to detect?

Inputs be will much appreciated.

ADB:
        10-20 12:37:00.997: D/BackupManagerService(527): Received broadcast Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:mobi.mgeek.TunnyBrowser flg=0x8000010 (has extras) }
    10-20 12:37:00.997: V/BackupManagerService(527): removePackageParticipantsLocked: uid=10112 #1
    10-20 12:37:01.007: D/dalvikvm(527): GC_EXPLICIT freed 2247K, 12% free 20128K/22868K, paused 3ms+10ms, total 212ms
    10-20 12:37:01.107: D/dalvikvm(527): GC_FOR_ALLOC freed 1508K, 15% free 19649K/22868K, paused 60ms, total 60ms
    10-20 12:37:01.137: D/AndroidRuntime(4028): Calling main entry com.android.commands.am.Am
    10-20 12:37:01.137: D/dalvikvm(4028): Note: class Landroid/app/ActivityManagerNative; has 163 unimplemented (abstract) methods
    10-20 12:37:01.147: I/ActivityManager(527): START u0 {act=android.intent.action.VIEW dat=http://survey.dolphin.com/int/uninstall?id=014f4d1981d6f88bb56630e7a3a7550a&pn=mobi.mgeek.TunnyBrowser&v=248&s=ofw&it=1382250136565&ut=1382250127000&m=Nexus 4&os=android&osv=4.3&cc=US&no=40471&lang=en&jk=uninstalled&ft=212&ht=957&ct=0&nt=1&res=768*1184&ifi=1&lts=1&iow=0&iom=0&iospd=0&iogs=0&debug=false&t=1382252820000 flg=0x10000000 cmp=com.android.chrome/com.google.android.apps.chrome.Main} from pid 4028
    10-20 12:37:01.157: D/AndroidRuntime(4028): Shutting down VM

解决方案

Here is a way you can get uninstall event of your own app.

Using inotify in native code. For example: You can using inotify_add_watch to monitor your application's data cache folder like: /data/data/your-package-name/cache.
When your application gets uninstalled, you can get the folder's delete event.

Another key point is that inotify should run in a seperate process from your own application.
You can invoke fork() to do this.

I've already verified the logic. :)

这篇关于安卓:听自己的应用程序卸载事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆