闪退

qq_4yn6fhv8 Android中基于Socke... 2019年03月27日提问

  • 0 回答
  • 96 浏览

2019-03-27 00:52:05.667 15936-15956/com.example.myapplication E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #2

    Process: com.example.myapplication, PID: 15936

    java.lang.RuntimeException: An error occurred while executing doInBackground()

        at android.os.AsyncTask$3.done(AsyncTask.java:353)

        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)

        at java.util.concurrent.FutureTask.setException(FutureTask.java:252)

        at java.util.concurrent.FutureTask.run(FutureTask.java:271)

        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)

        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)

        at java.lang.Thread.run(Thread.java:764)

     Caused by: java.lang.RuntimeException: Can't toast on a thread that has not called Looper.prepare()

        at android.widget.Toast$TN.<init>(Toast.java:390)

        at android.widget.Toast.<init>(Toast.java:114)

        at android.widget.Toast.makeText(Toast.java:277)

        at android.widget.Toast.makeText(Toast.java:267)

        at com.example.myapplication.MainActivity$3.doInBackground(MainActivity.java:79)

        at com.example.myapplication.MainActivity$3.doInBackground(MainActivity.java:67)

        at android.os.AsyncTask$2.call(AsyncTask.java:333)

        at java.util.concurrent.FutureTask.run(FutureTask.java:266)

        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245) 

        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) 

        at java.lang.Thread.run(Thread.java:764)