如何在android系统开机就运行某个应用
展开全部
如果需要在Android开机时自动启动应用程序,可以通过响应android.intent.action.BOOT_COMPLETED广播消息来实现, Android系统启动结束时,会发出 android.intent.action.BOOT_COMPLETED 消息。 具体步骤如下:1. 定义一个Broadcast Receiver ,比如:BootupReceiver
[java]
public class BootupReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
//better delay some time.
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Intent i = new Intent(context, BootupDemoActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
[java]
public class BootupReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
//better delay some time.
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Intent i = new Intent(context, BootupDemoActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询