tags:

views:

52

answers:

1

What does the following exception mean? And how can I fix it?

This is the code:

Toast toast = Toast.makeText(mContext, 'Somthing', Toast.LENGTH_SHORT);

This is the exception:

D/VVM ( 684): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() D/VVM ( 684): at android.os.Handler.(Handler.java:121) D/VVM ( 684): at android.widget.Toast.(Toast.java:68) D/VVM ( 684): at android.widget.Toast.makeText(Toast.java:231)

A: 

You're calling it from a worker thread. You need to call Toast.makeText() (and most other functions dealing with the UI) from within the main thread. You could use a handler, for example.

EboMike