首先,你需要将BootStarterReceiver添加到清单:
<receiver
android:name="com.nu.art.cyborg.common.utils.BootStarterReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
或者只是使BootStarterReceiver如果您使用的是最新版本(0.8.11 +)机器侠版本:
<receiver
android:name="com.nu.art.cyborg.common.utils.BootStarterReceiver"
android:enabled="true"/>
您还需要添加相应的权限:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
完成一个这样的设置,选择你的启动处理模块并实现OnBootCompletedListener,在onBootCompleted方法在那里执行你的代码。
至于盯着这一点的新活动......我不知道你的用户将如何回应,但你可以打电话给cyborg.startActivity(),意图将启动Cyborg的默认ApplicationLauncher和添加FLAG_ACTIVITY_NEW_TASK。
public void onBootCompleted() {
Intent intent = new Intent(getApplicationContext(), ApplicationLauncher.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
cyborg.startActivity(intent);
}