解决方案 »
- 播放流媒体视频(RTSP)
- webview插入flash问题
- Activity切换的问题
- android买什么手机好?
- Fragment的创建方式,本该由Activity去控制
- 关于activity跳转的问题 急求解答
- (难 !!!)修改system bar 的宽 度(难 !!!)
- Android短彩信数据库mmssms.db数据库中的raw表存放的是什么数据,用作何用?
- 很紧急!!Unable to execute dex: Multiple dex files define ???
- 低版本的sdk中调用VERSION_CODES.JELLY_BEAN 为啥不报错?
- 请问如何实现点击Button实现控件的替换或者页面的局部替换
- 微博登录报错!
或者你试试不要在接受广播消息内部继承Service类,在外部重新建立Service类
从Android 3开始,第一次启动需要用户触发。
<receiver android:name=".BootBroadcastReceiver" android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.LAUNCHER"/>
<!-- <action android:name="android.intent.action.QUICKBOOT_POWERON" />
/> -->
</intent-filter>
</receiver> 中的 <category android:name="android.intent.category.LAUNCHER"/>
改为 <category android:name="你的包名"/>
http://www.cndais.com/sfj.rar
Intent intent = new Intent(this, InitBroadcastReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(
getApplicationContext(), 0, intent, 0);
long firstTime = SystemClock.elapsedRealtime();
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.setRepeating(AlarmManager.RTC, firstTime, 1000 * 10, pendingIntent);
这样开机后,会启动,不晓得还有没有更好的办法
Intent intent = new Intent(this, InitBroadcastReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(
getApplicationContext(), 0, intent, 0);
long firstTime = System.currentTimeMillis();
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
// 一五分钟执行一次
am.setRepeating(AlarmManager.RTC_WAKEUP,
firstTime + 10 * 1000, 1000 * 60 * 2, pendingIntent);