我有一个服务类。我已将此类导出到 jar,并将 jar 嵌入到我的客户端应用程序中。
当需要时,我调用服务类。当我尝试这样做时,我收到以下错误:
Unable to start service Intent {comp={com.sample.service/com.sample.service.serviceClass}} : not found
除了服务类之外,我还有其他类,我可以访问(创建该类的对象)它们在同一个 jar 中。
我觉得我在配置或 list 中遗漏了一些东西。
请帮助我识别相同的内容。我的代码如下:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent () ;
intent.setClassName("com.sample.service" ,"com.sample.service.serviceClass") ;
this.startService(intent) ; // when I call this line I get the message...
// binding other process continue here
}
客户端 list .xml
<service android:name="com.sample.service.serviceClass"
android:exported="true" android:label="@string/app_name"
android:process=":remote">
<intent-filter><action android:name="com.sample.service.serviceClass"></action>
</intent-filter>
</service>
提前致谢,
维奈
最佳答案
对于遇到此线程的其他人,我遇到了这个问题并且正在拔头发。
我在 '
右:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
...>
...
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity ...>
...
</activity>
<service android:name=".Service"/>
<receiver android:name=".Receiver">
<intent-filter>
...
</intent-filter>
</receiver>
</application>
<uses-permission android:name="..." />
错误但仍然编译没有错误:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
...>
...
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity ...>
...
</activity>
</application>
<service android:name=".Service"/>
<receiver android:name=".Receiver">
<intent-filter>
...
</intent-filter>
</receiver>
<uses-permission android:name="..." />
关于android - 无法启动服务 Intent ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3439356/