Android5.0无法启动service

2017-06-13  本文已影响0人  CloudFlyKing

以下为service的配置

<service android:name=".service.QueryAndPostService">
            <intent-filter>
                <action android:name="com.wyf.queryandpost.service" />
            </intent-filter>
 </service>

启动service的代码如下

//启动Service
Intent intent = new Intent();
intent.setAction("com.bu.queryandpost.service");
context.startService(intent);

但是在5.0的系统里面就是启动不了
解决方法如下:

Intent i = new Intent(context, QueryAndPostService.class);
i.setPackage("包名");
i.setAction("com.bu.queryandpost.service");
context.startService(i);

完美解决

上一篇 下一篇

猜你喜欢

热点阅读