当前位置: 代码迷 >> Android >> android中关于service耗时同步事件的兑现
  详细解决方案

android中关于service耗时同步事件的兑现

热度:67   发布时间:2016-05-01 20:20:10.0
android中关于service耗时同步事件的实现
 private final class ServiceHandler extends Handler {        public ServiceHandler(Looper looper) {            super(looper);        }        @Override        public void handleMessage(Message msg) {            processMessage(msg);            // NOTE: We MUST not call stopSelf() directly, since we need to            // make sure the wake lock acquired by AlertReceiver is released.            AlertReceiver.finishStartingService(AlertService.this, msg.arg1);        }    }    @Override    public void onCreate() {        HandlerThread thread = new HandlerThread("AlertService",                Process.THREAD_PRIORITY_BACKGROUND);        thread.start();        mServiceLooper = thread.getLooper();        mServiceHandler = new ServiceHandler(mServiceLooper);    }    @Override    public int onStartCommand(Intent intent, int flags, int startId) {        if (intent != null) {            Message msg = mServiceHandler.obtainMessage();            msg.arg1 = startId;            msg.obj = intent.getExtras();            mServiceHandler.sendMessage(msg);        }        return START_REDELIVER_INTENT;    }    @Override    public void onDestroy() {        mServiceLooper.quit();    }    @Override    public IBinder onBind(Intent intent) {        return null;    }
?

?

  相关解决方案