1
AndroidManifest.xml中无法通过隐意图启动意图服务
<application android:name=".MyApplication"
android:icon="@drawable/icon"
android:label="@string/app_name"
>
<service android:name=".MyService"
android:exported="true">
<intent-filter>
<action android:name="android.service.myapp.MyService.actionA"/>
<action android:name="android.service.myapp.MyService.actionB"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</service>
</application>
如果我使用下面的代码,我的服务启动:
Intent intent = new Intent(context, MyService.class);
intent.setAction("android.service.myapp.MyService.actionA");
context.startService(intent);
但如果我启动它我的服务未启动与此代码:
Intent intent = new Intent("android.service.myapp.MyService.actionA");
context.startService(intent);