Android 更新完成后如何自动重启应用程序?

Android 更新完成后如何自动重启应用程序?,android,Android,在谷歌之后,我决定这样做: <receiver android:name=".UpdateReceiver"> <intent-filter> <action android:name="android.intent.action.ACTION_MY_PACKAGE_REPLACED" /> </intent-filter> </receiver> 由于设备是根设备,因此请使用以下代码进行更新: comm

在谷歌之后,我决定这样做:

<receiver android:name=".UpdateReceiver">
    <intent-filter>
       <action android:name="android.intent.action.ACTION_MY_PACKAGE_REPLACED" />
    </intent-filter>
</receiver>
由于设备是根设备,因此请使用以下代码进行更新:

command = "pm install -r " + "/mnt/sdcard/Download/xxx.apk";                                               
Process proc = Runtime.getRuntime().exec(new String[]{"su", "-c", command});
proc.waitFor();
更新成功,但UpdateReceiver未触发,为什么


我的设备OS verison是4.4.4。我从自己的服务器上更新应用程序。

它不是
android.intent.action.action\u我的软件包\u被替换了
。 它是
android.intent.action.MY\u PACKAGE\u替换的

<receiver android:name=".UpdateReceiver">
    <intent-filter>
       <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
    </intent-filter>
</receiver>


官方文件说,api级别>12时无需传递数据是的,对此表示抱歉。我已经更新了我的答案。操作名称是android.intent.action.MY_PACKAGE_REPLACE,而不是android.intent.action.action_MY_PACKAGE_REPLACE是的,谢谢,我的打字错误是因为老板让我快点完成:)
<receiver android:name=".UpdateReceiver">
    <intent-filter>
       <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
    </intent-filter>
</receiver>