android开机自启动app示例分享
/*开机自动启动APP*/
public class BootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d("XRGPS", "BootReceiver.onReceive: " + intent.getAction());
if (ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
Intent mBootIntent = new Intent(context, MainActivity.class);
mBootIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(mBootIntent);
} else {
Log.w("XRGPS", "BootReceiver: unsupported action");
}
}
}
上一篇:android中在Activity中响应ListView内部按钮的点击事件的两种方法
栏 目:Android代码
本文标题:android开机自启动app示例分享
本文地址:http://www.codeinn.net/misctech/180582.html