无法启动服务意向 [英] Unable to start Service Intent
问题描述
我有一个服务类。我已经远销这个类来坛子里,我已经嵌入在我的客户端应用程序的jar。
I have a service class. I have exported this class to jar and I have embed the jar in my client app.
当需要时,我打电话到服务类。当我尝试这样做,我得到以下错误:
When needed, I call the service class. When I try to do this, I get the following error:
无法启动服务意向{补偿= {com.sample.service / com.sample.service.serviceClass}}:未找到
Unable to start service Intent {comp={com.sample.service/com.sample.service.serviceClass}} : not found
我有其他类除了服务类,我能够访问(创建该类的对象),它们是同一个瓶子里。
I have other class apart from the service class, which I am able to access (create object of that class) which are inside the same jar.
我觉得我已经错过了在我的配置有些东西还是明显的左右。
I feel I have missed out some thing in my configuration or manifest or so.
请帮我找出相同。我的code是如下:
Please help me identifying the same. My code is below:
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
}
客户端的manifest.xml
Client manifest.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>
在前进,
谢谢
维奈
Thanks in advance,
Vinay
推荐答案
首先,你不需要安卓程序=:远程
,所以请删除它,因为所有它做的是占用额外的内存对于任何好处。
First, you do not need android:process=":remote"
, so please remove it, since all it will do is take up extra RAM for no benefit.
二,因为&LT;服务&GT;
元素包含一个操作字符串,使用它:
Second, since the <service>
element contains an action string, use it:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent=new Intent("com.sample.service.serviceClass");
this.startService(intent);
}
这篇关于无法启动服务意向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!