0
我把這個例子從android網站上的服務搞亂了。該服務旨在稱呼敬酒。我使用按鈕的onClick方法啓動服務。它的作品,但敬酒永遠不會結束!我認爲IntentService在該過程完成後會自行停止。Android IntentService調用不會自行停止的烤麪包
import android.app.IntentService;
import android.content.Intent;
import android.widget.Toast;
public class Enslaved extends IntentService {
public Enslaved() {
super("Enslaved");
}
@Override
protected void onHandleIntent(Intent intent) {
Toast.makeText(this, "Starting service", Toast.LENGTH_SHORT).show();
}
}
謝謝山姆。你太棒了。 – Hovanky