Java – How do I know if Looper is running?

How do I know if Looper is running?… here is a solution to the problem.

How do I know if Looper is running?

Sometimes I find this anomaly :

Cannot create a handler inside a thread that has not yet called Looper.prepare().

How do I know if Looper.myLooper() calls prepare?

ps – my English is not good

Solution

If you call Looper.myLooper(), it returns null if prepare has not been called. To view the source:

http://androidxref.com/5.1.1_r6/xref/frameworks/base/core/java/android/os/Looper.java

Related Problems and Solutions