Created
October 31, 2013 03:07
-
-
Save bobbyflowstate/7243840 to your computer and use it in GitHub Desktop.
Building HandlerThread for IntentService
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GCMIntentService extends GCMBaseIntentService { | |
. | |
. | |
. | |
private Looper mServiceLooper; | |
public GCMIntentService() { | |
. | |
. | |
. | |
HandlerThread thread = | |
new HandlerThread("UmanoGCMIntentService:WorkerThread", | |
Process.THREAD_PRIORITY_BACKGROUND); | |
thread.start(); | |
mServiceLooper = thread.getLooper(); | |
} | |
@Override | |
protected void onMessage(Context context, Intent intent) { | |
Handler h = new Handler(mServiceLooper); | |
h.post(new Runnable() { | |
@Override | |
public void run() { | |
// Execute network fetch here. | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment