解决方案 »
- android掉用WCF的正确方式
- powermanagerservice.java中怎么让键盘灯亮
- 请教handler消息发送问题
- android做音乐播放器mediastore查询的问题。
- android 本地数据库 与远程数据库 同步
- android 通知 不显示在通知列表中
- MKSearchListener中onGetAddrResult方法里错误码3的含义
- 新人求助:网页上有一些键值对,Android怎样读取它们?
- Android Dialog如何显示在指定控件的下面
- edittext的TextWatcher回调时listview的数据源空了
- 1.6项目顺利运行在2.0模拟器上
- 关于activity生命周期中onRestart的一个问题
记得模拟器好些可以模拟开关机的,我2.3的模拟器长按挂机键,在最后的Power off dialog就停那里关不了也开不了。
有没有在AndroidManifest.xml设置好intent-filter??<receiver android:name=".BootBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
<receiver android:enabled="true" android:name="bli.weather.receiver.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.INTERNET"></uses-permission>
public class BootUpReceiver extends BroadcastReceiver {
public void onReceive(Context context,Intent intent) {
Log.e("BootUpReceiver", "BootUpReceiver");
Intent i = new Intent(Model.MainServiceActivion);
//i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startService(i);
Log.e("BootUpReceiver", Model.MainServiceActivion);
Log.e("BootUpReceiver", "BootUpReceiver");
}
}
public void onReceive(Context context,Intent intent) {
if("android.intent.action.BOOT_COMPLETED".equalsIgnoreCase(intent.getAction())) {
} }
}
试下吧
我用它start不在一个包的service就会空指针,在一个包的就不会。我吧category android:name="android.intent.category.DEFAULT"这句注释掉了
<intent-filter>
<action android:name="bli.weather.service.MainService" />
</intent-filter>
</service>
<service android:enabled="true" android:name="bli.weather.service.BootUpService">
</service>