按照教程设置了开机启动,可是测试时服务启动不了<receiver android:name=".RunReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
<service
android:name=".BellService">
<intent-filter>
<action android:name="autobell.intent.action.startservice" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</service>
public class RunReceiver extends BroadcastReceiver { public RunReceiver() {
// TODO Auto-generated constructor stub
} @Override
public void onReceive(Context context, Intent arg1) {
// TODO Auto-generated method stub
Intent intent = new Intent(context,BellService.class);
intent.setAction("autobell.intent.action.startservice");
context.startService(intent);
}}
哪里出了问题呢?
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
<service
android:name=".BellService">
<intent-filter>
<action android:name="autobell.intent.action.startservice" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</service>
public class RunReceiver extends BroadcastReceiver { public RunReceiver() {
// TODO Auto-generated constructor stub
} @Override
public void onReceive(Context context, Intent arg1) {
// TODO Auto-generated method stub
Intent intent = new Intent(context,BellService.class);
intent.setAction("autobell.intent.action.startservice");
context.startService(intent);
}}
哪里出了问题呢?
解决方案 »
- android 错误 error opening trace file:
- 小弟不才,求一个用其他软件来打开word和ppt文件的方法
- android 布局问题
- sendBroadcast后BroadcastReceiver没有收到intent
- Android接收短信,在真机上测试有问题
- eclipse真机调试安装的奇怪问题
- 运行模拟器后的时间是根据什么来的?如何令时间和笔记本上的时间一致?
- 通过Intent进入wifi settings的应用
- 请问如何设置弹出菜单(popupMenu)的背景颜色或style
- 请教关于安卓向别的应用发送模拟按键功能的实现
- android中ts流文件格式
- Window8要出了,请问下android和.net的就业前景哪个更好
intent.setAction("autobell.intent.action.startservice");另外,在RunReceiver里面加上Log,i("test", "有执行");然后重新启动看查看LogCat是否有输出这段文字。