package com.panpass.main; import android.app.IntentService; import android.content.Intent; import android.util.Log; public class MyIntentService extends IntentService { public MyIntentService() { super("MyIntentService"); } @Override protected void onHandleIntent(Intent intent) { try { Thread.sleep(2000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } Log.i("DD",intent.getStringExtra("action")+"完成"); } @Override public void onDestroy() { Log.i("DD","onDestroy"); } }
Intent intent1 = new Intent(this,MyIntentService.class); intent1.putExtra("action", "one"); Intent intent2 = new Intent(this,MyIntentService.class); intent2.putExtra("action", "two"); startService(intent1); startService(intent2);
01-16 17:01:39.710: I/DD(29268): one完成 01-16 17:01:41.712: I/DD(29268): two完成 01-16 17:01:41.712: I/DD(29268): onDestroy
时间: 2024-10-18 19:39:21