我在应用程序“ServiceDemo”中有一个服务MyService.java。这个应用程序的清单看起来像这样如何执行远程服务
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.moto.dev"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Sample"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:enabled="true"
android:name=".MyService"
android:permission="syh.permission.STARTMYSERVICE">
</service>
</application>
<permission
android:protectionLevel="normal"
android:label="Start My Receiver"
android:description="@string/startMyActivityDesc"
android:name="syh.permission.STARTMYSERVICE">
</permission>
<uses-sdk android:minSdkVersion="8" />
</manifest>
我有另一个应用程序“CallerService”清单看起来像这样
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.moto.dev"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".CallerService"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="syh.permission.STARTMYSERVICE"></uses-permission>
<uses-sdk android:minSdkVersion="8" />
"src/com/moto/dev/Sample.java"</manifest>
我从那里我米试图上的点击启动服务活动按钮
Intent intent = new Intent();
//path where my service is located in application "ServiceDemo"
intent.setClassName("com.moto.dev","com.moto.dev.MyService");
startService(intent);
这失败了。说“无法启动服务意图” 我可以知道我哪里出错了。