我有一个服务舱。我已经将这个类导出到jar中,并将jar嵌入到我的客户端应用程序中。
当需要时,我调用服务类。当我尝试这样做时,我得到了以下错误:
Unable to start service Intent {comp={com.sample.service/com.sample.service.serviceClass}} : not found
除了服务类之外,我还有其他类,我可以访问这些类(创建该类的对象),它们位于同一个jar中。
我觉得我在配置或清单中遗漏了一些东西。
请帮我确认一下。我的代码如下:
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
<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>
提前谢谢你,
维奈
发布于 2010-08-09 20:10:17
首先,您不需要android:process=":remote"
,所以请删除它,因为它只会占用额外的内存而没有任何好处。
其次,由于<service>
元素包含一个操作字符串,因此使用它:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent=new Intent("com.sample.service.serviceClass");
this.startService(intent);
}
发布于 2011-05-06 12:22:52
1)检查清单中的服务声明是否嵌套在应用程序标签中
<application>
<service android:name="" />
</application>
2)检查您的service.java
是否在与活动相同的包或diff包中
<application>
<!-- service.java exists in diff package -->
<service android:name="com.package.helper.service" />
</application>
<application>
<!-- service.java exists in same package -->
<service android:name=".service" />
</application>
发布于 2016-12-15 22:09:31
在我的例子中,按意图传输数据的最大上限为1MB。我将只使用缓存或存储。
https://stackoverflow.com/questions/3439356
复制相似问题