我有一個意向服務,我從一個單獨的進程(我已將它包含在清單中)開始,並且正在啓動進程,但是我在開始時的日誌OnHandleIntent永遠不會被調用。我希望這是一個獨立的過程,因爲它正在做一些繁重的工作,並且需要它能夠掌握的所有內存。OnHandleIntent不在Intent服務中調用
這是服務代碼:
public class ProcessingService extends IntentService {
private final String TAG = "Processing Service";
public ProcessingService() {
super("ProcessingService");
}
@Override
protected void onHandleIntent(Intent intent) {
Log.d(TAG, "On Handle started");
/../
}
}
而且這裏是我開始吧:
public void doneBtn(View v) {
Log.d(TAG, "button pressed, starting service");
Intent intent = new Intent(MyActivity.this, ProcessingService.class);
startService(intent);
finish();
}
我也打過電話與應用程序上下文,相同的結果的服務。
當然在清單中,裏面的應用範圍:
<service android:name=".myapp.task.ProcessingService" android:process=":myserviceprocess"/>
按鈕被按下時,在創建過程中和活動結束,但在日誌中onHandleIntent是從來沒有發射(和沒有的在那裏做其他工作)。將Intent Service放在單獨的進程上有什麼不可思議的東西嗎?我應該做一個常規的服務,然後產生一個異步的任務關閉它或什麼?
當您從Manifest中刪除android:process屬性時它工作嗎? – ianhanniballake 2013-03-01 21:54:31
不,結果相同(除了明顯沒有創建新進程) – adonal3 2013-03-04 15:55:08