2013-06-11 86 views
1

我想知道如何啓動一個即使在業務關閉時也能繼續運行的android服務。當活動停止時不停止服務

我用這個代碼:

Intent intent = new Intent(this, MyTestService.class);   
bindService(intent,connection, Context.BIND_AUTO_CREATE); 

謝謝。

回答

1

你可以嘗試

startService(new Intent(this, MyTestService.class)); 

Intent intent = new Intent(this, MyTestService.class); 
2
Intent intent = new Intent(this, MyTestService.class); 
startService(intent); 
+0

謝謝你,但我想保持我的ServiceConnection捕捉進行綁定時 – unamedUser

+1

可以保持兩個方法,簡稱「startService」之前。 –