我的IntentService怎么启动不了呢?

charlesxu 2015-06-04 08:38:06
debug了下,能执行到this.startService(mServiceIntent);然后就没反应了,即进不了IntentServcie的onCreate,也进不了onHandleIntent

manifest里的注册:

<application>
<service android:name="com.aaa.ggg.IntentServcie_my"/>
</application>


IntentService的代码:

public class BackgroundService extends IntentService {
public BackgroundService() {
super("BackgroundService");
}
@Override
protected void onHandleIntent(Intent intent) {
String tmp = intent.getStringExtra("strr")
}
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
}


在Activity里启动IntentServcie的代码

Intent mServiceIntent = new Intent(this, com.aaa.ggg.IntentServcie_my.class);
mServiceIntent.putExtra("strr", "str_val");
this.startService(mServiceIntent);
...全文
574 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
李磊LL 2017-04-27
  • 打赏
  • 举报
回复
我也遇到了这个问题 怎么都启动不了service
韩广通 2017-01-02
  • 打赏
  • 举报
回复
mainfest 里添加 <service android:name=".yourActivity$yourservice" />
oiyrwerwef 2016-02-23
  • 打赏
  • 举报
回复
楼主解决了吗。。
Birds2018 2015-06-04
  • 打赏
  • 举报
回复
一个Service只会启动一次,如果再启动 只会重新调用onStartCommand方法,实例只是一个而已。 你Debug一下,如果是同一个进程是可以调试的。
charlesxu 2015-06-04
  • 打赏
  • 举报
回复
BackgroundService和IntentServcie_my是一样的,我就改了个名字,有一个没改。 IntentServcie和activity是不在一个包里,可另一个不同包的IntentServcie就能启动。 还有在IntentServcie里还能再启动另一个IntentServcie吗?就像Thread里能再起个Thread吗?谢谢
引用 1 楼 birdsaction 的回复:
BackgroundService 和配置的com.aaa.ggg.IntentServcie_my.class 不一样啊。 Intent mServiceIntent = new Intent(this, BackgroundService .class); mServiceIntent.putExtra("strr", "str_val"); this.startService(mServiceIntent); <service android:name="BackgroundService "/>
Arnold9009 2015-06-04
  • 打赏
  • 举报
回复
估计lz是把service放在一个单独的包里了 参考一下这个试试:http://blog.csdn.net/mad1989/article/details/38090513
Birds2018 2015-06-04
  • 打赏
  • 举报
回复
BackgroundService 和配置的com.aaa.ggg.IntentServcie_my.class 不一样啊。 Intent mServiceIntent = new Intent(this, BackgroundService .class); mServiceIntent.putExtra("strr", "str_val"); this.startService(mServiceIntent); <service android:name="BackgroundService "/>

80,471

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧