I am facing some problems when I'm using Toast inside run method of Thread class.
My error Logcat
09-16 11:42:38.140: E/AndroidRuntime(1446): in writeCrashedAppName, pkgName :com.monday.worker_android
09-16 11:59:17.920: E/AndroidRuntime(2144): FATAL EXCEPTION: AsyncTask #1
09-16 11:59:17.920: E/AndroidRuntime(2144): java.lang.RuntimeException: An error occured while executing doInBackground()
09-16 11:59:17.920: E/AndroidRuntime(2144): at android.os.AsyncTask$3.done(AsyncTask.java:200)
09-16 11:59:17.920: E/AndroidRuntime(2144): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
09-16 11:59:17.920: E/AndroidRuntime(2144): at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
09-16 11:59:17.920: E/AndroidRuntime(2144): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
09-16 11:59:17.920: E/AndroidRuntime(2144): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
09-16 11:59:17.920: E/AndroidRuntime(2144): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
09-16 11:59:17.920: E/AndroidRuntime(2144): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
09-16 11:59:17.920: E/AndroidRuntime(2144): at java.lang.Thread.run(Thread.java:1019)
09-16 11:59:17.920: E/AndroidRuntime(2144): Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
09-16 11:59:17.920: E/AndroidRuntime(2144): at android.os.Handler.<init>(Handler.java:121)
09-16 11:59:17.920: E/AndroidRuntime(2144): at android.widget.Toast.<init>(Toast.java:75)
09-16 11:59:17.920: E/AndroidRuntime(2144): at android.widget.Toast.makeText(Toast.java:244)
09-16 11:59:17.920: E/AndroidRuntime(2144): at com.monday.worker_android.SwipePage$2.doInBackground(SwipePage.java:142)
09-16 11:59:17.920: E/AndroidRuntime(2144): at com.monday.worker_android.SwipePage$2.doInBackground(SwipePage.java:1)
09-16 11:59:17.920: E/AndroidRuntime(2144): at android.os.AsyncTask$2.call(AsyncTask.java:185)
09-16 11:59:17.920: E/AndroidRuntime(2144): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
But when I ignore Toast it works fine. But I want to use it. Please help.