简体   繁体   English

android:从应用程序代码中检测应用程序的重新安装

[英]android : detect the reinstall of an app from the app code

Is there a way to detect from app code when it is being reinstalled. 有没有办法在重新安装时检测应用程序代码。

I saw that app update from market can be detected by listening to PACKAGE_REPLACED event in broadcast receiver. 我看到可以通过收听广播接收器中的PACKAGE_REPLACED事件来检测市场上的应用更新。 But that these events are not delivered to the app , if the app is reinstalled from editor (eclipse ). 但是,如果从编辑器(eclipse)重新安装应用程序,则这些事件不会传递给应用程序。

My requirement is that i am disabling a component(Launcher activity). 我的要求是我禁用了一个组件(Launcher活动)。 The app install will fail if it is not enabled. 如果未启用,则应用安装将失败。 SO everytime before reinstall i want to enable this component. 每次重新安装之前我想启用此组件。

I am talking about the reinstall before publishing in market. 我在谈论重新安装之前在市场上发布。 While developing , each time i reinstall the app to test some modification, i want to detect this from my app and make the component enabled. 在开发时,每次我重新安装应用程序以测试一些修改时,我想从我的应用程序中检测到这一点并启用该组件。

I saw from my example that the following events will be broadcasted when an app is reinstalled from eclipse. 我从我的例子中看到,当从eclipse重新安装应用程序时,将播放以下事件。

<intent-filter>
        <action android:name="android.intent.action.PACKAGE_ADDED"/>
        <action android:name="android.intent.action.PACKAGE_REPLACED"/>
             </intent-filter>

I defined a broadcast receiver for these actions and from onreceive i am able to enable my component 我为这些动作定义了一个广播接收器,从onreceive我能够启用我的组件

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM