项目需要android开机自动启动一个app的界面,网上找了些资料,证实可用:
首先是在你要启动的app的 AndroidManifest.xml文件里面加下面一段代码(注意是加在application标签内):
< receiver android:enabled ="true" android:name =".BootUpReceiver"

android:permission ="android.permission.RECEIVE_BOOT_COMPLETED" >

< intent-filter >

< action android:name ="android.intent.action.BOOT_COMPLETED" />

< category android:name ="android.intent.category.DEFAULT" />

</ intent-filter >

</ receiver >

< uses-permission android:name ="android.permission.RECEIVE_BOOT_COMPLETED" />
之后在项目里面创建一个 BootUpReceiver的类( MyActivity是你自己的app的main activity ): public class BootUpReceiver extends BroadcastReceiver{
public void onReceive(Context context, Intent intent) {
Intent i = new Intent(context, MyActivity. class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
之后编译运行,再启动系统的时候,app就可以在系统启动完成之后自动运行啦

更多相关文章

  1. Android通过selector改变界面状态
  2. Android 项目实例config.gradle配置
  3. GitHub最火的android 项目
  4. Android 导入项目时报Android.jar包丢失解决方法
  5. Android NDK探究奥秘一:Android Studio创建第一个JNI项目
  6. Android牟利之道(一)--界面嵌入有米广告
  7. GitHub上优秀Android 开源项目

随机推荐

  1. Android(安卓)Interface Definition Lang
  2. Android(安卓)PopWindow使用
  3. Android日期时间格式国际化
  4. android
  5. Android(安卓)Launcher3一些默认修改
  6. 安卓开发模拟器运行时报错原因以及解决方
  7. 迁移到Android(安卓)Studio 3.0
  8. delphi xe5 android 控制蓝牙
  9. android web services
  10. TextView字体逐渐变淡点以及程序特定list