首页 > 其他 > 详细

======IntentService======

时间:2015-01-16 20:59:19      阅读:303      评论:0      收藏:0      [点我收藏+]
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




======IntentService======

原文:http://blog.csdn.net/soulofandroid/article/details/42779369

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!