Created
July 25, 2012 17:43
-
-
Save forforf/3177475 to your computer and use it in GitHub Desktop.
Android - Custom Handler Thread
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
//Note that this mostly duplicates Android's HandlerThread class | |
// so that one might be a better choice | |
// The only thing this one has going for it is that the handler is part | |
// of the thread instance, but this may not be as flexible. | |
public class MyHandlerThread extends Thread { | |
private static final String TAG = "MyThread"; | |
public Handler mHandler; | |
private static int thrCount = 1; | |
public MyHandlerThread() { | |
super(TAG + thrCount); | |
thrCount += 1; | |
mHandler = null; | |
} | |
public void run() { | |
Log.d(TAG,"starting"); | |
Log.d(TAG,"Message Handler"); | |
Looper.prepare(); | |
//Handler handler = new Handler(); | |
mHandler = new Handler(); | |
Looper.loop(); | |
Log.d(TAG,"exiting"); | |
} | |
public void test(){ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment