`
baobaoupup
  • 浏览: 472099 次
文章分类
社区版块
存档分类
最新评论

Android开机启动程序

 
阅读更多

下面把我刚写好的 代码贴上

下面这个类 是接收系统开机时候发送广播的


下面这个类 是开启一个服务的 ,只要服务能启动到后台 起一个程序也是没问题的


配置文件需要添加的信息

这里需要提示一点 android系统开机后 就会发出广播,这时候启动服务是需要延迟启动的,不然可是看不到后台服务的。具体怎么做。我写了一个定时器启动,程序挂掉了、、、、接着测。稍后补上

测了一下 原因是忘配 <service android:name=".MyService"></service> 这个了

加完 定时 启动服务 可以了


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

这句话 不知道什么意思,我自己猜想 可能是一个主界面的类别

sdk 提到过一嘴

It then displays the icons and labels of those activities in the launcher. Similarly, it discovers the home screen by looking for the activity with "android.intent.category.HOME" in its filter.

貌似 好像 是开机界面时候 才能接收到这个开机广播 等我把 定时器去了 再试试

测完了 , 不测了 总结:

的确 和定时器没有关系 而且启用定时器的话

02-10 17:16:52.000: ERROR/AndroidRuntime(471): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
消息队列会阻塞 挂掉启动Service的进程。。。。

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

这句话的意思 显而易见 就是加载完 主页面后 才会执行接收到系统开机广播要启动的服务。。。。可以见得写框架的这帮人是多么的有才。厉害人太多了,学吧。。


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics