我希望我的应用在更新后自动重启。 以下是我的清单和广播接收者代码:
...
<receiver
android:name="app.com.blynq.services.BootReceiver"
android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.SCREEN_ON" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package" android:path="app.com.blynq.player" />
</intent-filter>
</receiver>
...
服务:
public class BootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String intentActionString = intent.getAction();
if ("android.intent.action.BOOT_COMPLETED".equals(intentActionString) || "android.intent.action.PACKAGE_REPLACED".equals(intentActionString)) {
Intent pushIntent = new Intent(context, RegisterActivity.class);
pushIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(pushIntent);
}
}
我在这里缺少什么?