• Service_Basics

    Service Basics  Service Basics

    ** A Service runs with the main application thread , so some time user interaction will lock the current application . Use Service inside a separate thread, you will reduce the risk of Application Not Responding (ANR) errors . So  application's main thread can remain dedicated to user interaction with your activities.

    ** If you are starting service inside any activity then it will block activity so when created service done then only your activity will unlock. in this mean time if user will interacting to activity then Application Not Responding (ANR) errors will come.

    ** If you want user interaction on when activity is visible and also some server or time taking tasks(performs intensive or blocking operations) then you might create a thread in onCreate(), start running it in onStart(), then stop it in onStop(). Also consider using AsyncTask or HandlerThread, instead of the traditional Thread class

    Read More