Service

 

Toast.makeText(MainActivity.this,str,Toast.LENGTH_SHORT).show();

 

extends Service > onCreate, onDestroy, onStartCommand, onBind().

 

Intent intent = new Intent(MainActivity.this, ExapleService.class;

startService(intent);

stopService();

  START_STICKY, START_NON_STICKY,START_REDELIVER_INTENT

 

Message.obtain() or Handler.obtainMessage() to get Message object. Remove from MessageQueue, put into 

 

pool.

Looper 1to1 MessageQueue. e.g. Looper.myLooper()

Handler nto1 Looper/MessageQueue.

 

Looper looper = looper.getMainLooper();

handler=new ServiceHandler();

extends Handler

Message msg = Handler.obtainMessage();

msg.what="xxx";

msg.arg1="xxx";

msg.obj="xxx";

handler.sendMessage(msg);


你可能感兴趣的:(service)