我有一個服務類。我已經將這個類導出到jar,並且我已經將jar嵌入到了我的客戶端應用程序中。無法啓動服務意圖
需要時,我打電話給服務類。當我嘗試這樣做,我得到以下錯誤:
Unable to start service Intent {comp={com.sample.service/com.sample.service.serviceClass}} : not found
我除了有其他類從服務類,我能夠訪問(創建該類的對象),這是相同的罐子裏。
我覺得我錯過了我的配置或清單等東西。
請幫我鑑定一下。我的代碼如下:
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>
在此先感謝,
維奈
我試圖修復你的代碼,但是在源代碼中有一些問題,我覺得我不夠理解它。基本上你在中有一個額外的空間,它應該是,但是如果你看看源代碼,你在兩個import語句前有一個'/',我不確定它們是否應該在那裏。我認爲'<'之後的空格將成爲你問題的原因。 –
2010-08-09 11:15:01
感謝詹姆斯的回覆。這些空間是故意僅在網站上顯示的。在代碼內部,標籤內部沒有空格。即使是「\」只能在網站上正確顯示。 基本上,我在eclipse中沒有得到任何編譯錯誤。只有在運行時,我在LogCat – Vinay 2010-08-09 11:55:39