标签:
<service android:name=".MyPushOrderService" android:label="@string/app_name" android:enabled="true" > <intent-filter> <!-- 接收到通知后处理的Service --> <action android:name="com.lanshui.mobile.MYGETPUSH_ORDER_ACTION" /> </intent-filter> </service>
以上为在配置文件里配置的service
启动代码:
//启动Service处理任务 Intent intent = new Intent(); intent.setAction("com.lanshui.mobile.MYGETPUSH_ORDER_ACTION"); context.startService(intent);
但是在5.0里怎么都启动不来,弄了半天,结果如下:
去掉配置文件里的配置service
直接启动代码如下:
Intent intent = new Intent(context, MyPushOrderService.class); context.startService(intent);
这就够了。
##########那么问题来了,在4.2.2上又测了下,这下也没法启动Service了。。。
无解,索性将两种方式合并啊。。。新代码如下:
第一步添加注册配置:
<service android:name=".MyPushOrderService" android:enabled="true" android:label="@string/app_name" > <intent-filter> <!-- 接收到通知后处理的Service --> <action android:name="com.lanshui.mobile.MYGETPUSH_ORDER_ACTION" /> </intent-filter> </service>
//启动Service处理任务 Intent intent = new Intent(context, MyPushOrderService.class); intent.setAction("com.lanshui.mobile.MYGETPUSH_ORDER_ACTION"); context.startService(intent);
有更好的方式,请留言哦,继续完善。。。
标签:
原文地址:http://my.oschina.net/gabriel1215/blog/498262