码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-01-16 21:01:01      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:android

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======

标签:android

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!