Intent Service

If you need to perform any operation asynchronus or queue and that process will be automatically killed after it has done.Since intent service works on worker thread so launching multiple intent will be done one by one and will be killed after it has done with it.Since its run on single thread it will be time consuming.

starting an intent service

public void startService(View view){ Intent intent=new Intent(this,MyService.class); startService(intent); }

stopService()

public void stopService(View view){ Intent intent=new Intent(this,MyService.class); stopService(intent); }

override method when we extend intent service

@Override protected void onHandleIntent(Intent intent){ synchronize (this){ try{ wait(20000); }catch(IntarruptedException e){ e.printStackTrace(); } } }