10 Service02

package com.szy.service;

import android.app.IntentService;
import android.content.Intent;
import android.util.Log;

public class ExampleIntentService extends IntentService
{
    protected static final String TAG = "IntentActivity";
    
    public ExampleIntentService()
    {
        super("ExampleIntentService");
    }

    @Override
    protected void onHandleIntent(Intent intent)
    {
        
        try
        {
            Log.i(TAG, "MyService线程ID:"+Thread.currentThread().getId());
            Log.i(TAG, "文件下载....");
            Thread.sleep(2000);
        } catch (InterruptedException e)
        {
            e.printStackTrace();
        }

    }

}
IntentService在
onHandleIntent(Intent intent)中实现异步操作。
posted @ 2014-04-28 22:16  阿黄的苹果  阅读(92)  评论(0编辑  收藏  举报