10 Service02

时间:2014-04-29 18:02:50   收藏:0   阅读:432
bubuko.com,布布扣
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();
        }

    }

}
bubuko.com,布布扣
IntentService在
onHandleIntent(Intent intent)中实现异步操作。

10 Service02,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!