pengkobe / reading-notes

:stars: to record daily reading notes. I build an issue blog to record daily FE study notes. suggestion and comments are welcomed.
https://github.com/pengkobe/reading-notes/issues
MIT License
13 stars 1 forks source link

ANDROID 随系统自启动 #519

Open pengkobe opened 2 years ago

pengkobe commented 2 years ago

具体需求不是简简单单的开机启动,而是需要不经过桌面直接启动,如果你有厂商的联系方式,其实还是比较好办的,直接按照教程一步一步来就 ok,他们会帮你适配。

这里列一下一般的处理步骤,具体可以参考 https://www.jianshu.com/p/92cc2b41443b

  1. 定义一个开机广播接收者 BootBroadcastReceiver
  2. 在 app 配置文件中添加权限 RECEIVE_BOOT_COMPLETED
  3. 注册广播 BOOT_COMPLETED

于此同时,也可以设置为系统桌面,在 mainactivity 的 intent-fliter 标签里添加下面的代码

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

即可

参考

  1. 将某一普通应用设为桌面(launcher)的方法
  2. Cordova如何设置