1) In android for background tasks
If short –> can use AsyncTask
If long –> Use a Service and propagate the changes to the main activity with a BroadcastReceiver
2) Favor static inner classes over nonstatic. Each instance of a nonstatic inner class will have an extraneous reference to its outer Activity instance. Storing this reference can result in the Activity being retained when it would otherwise be eligible for garbage collection. If your static inner class requires a reference to the underlying Activity in order to function properly, make sure you wrap the object in a
WeakReference to ensure that you don’t accidentally leak the Activity.