-2

Android でこのエラーが発生していますが、これToastを理解できません。

05-23 03:22:33.415: E/AndroidRuntime(706): FATAL EXCEPTION: AsyncTask #1
05-23 03:22:33.415: E/AndroidRuntime(706): java.lang.RuntimeException: An error occured while executing doInBackground()
05-23 03:22:33.415: E/AndroidRuntime(706):  at android.os.AsyncTask$3.done(AsyncTask.java:278)
05-23 03:22:33.415: E/AndroidRuntime(706):  at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
05-23 03:22:33.415: E/AndroidRuntime(706):  at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
05-23 03:22:33.415: E/AndroidRuntime(706):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
05-23 03:22:33.415: E/AndroidRuntime(706):  at java.util.concurrent.FutureTask.run(FutureTask.java:137)
05-23 03:22:33.415: E/AndroidRuntime(706):  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
05-23 03:22:33.415: E/AndroidRuntime(706):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
05-23 03:22:33.415: E/AndroidRuntime(706):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
05-23 03:22:33.415: E/AndroidRuntime(706):  at java.lang.Thread.run(Thread.java:864)
05-23 03:22:33.415: E/AndroidRuntime(706): Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
05-23 03:22:33.415: E/AndroidRuntime(706):  at android.os.Handler.<init>(Handler.java:121)
05-23 03:22:33.415: E/AndroidRuntime(706):  at android.widget.Toast$TN.<init>(Toast.java:317)
05-23 03:22:33.415: E/AndroidRuntime(706):  at android.widget.Toast.<init>(Toast.java:91)
05-23 03:22:33.415: E/AndroidRuntime(706):  at android.widget.Toast.makeText(Toast.java:233)
05-23 03:22:33.415: E/AndroidRuntime(706):  at com.example.devicecontrolpanel.TestActivity$DeviceSearcher.executed(TestActivity.java:482)
05-23 03:22:33.415: E/AndroidRuntime(706):  at com.example.devicecontrolpanel.TestActivity$DeviceSearcher.doInBackground(TestActivity.java:289)
05-23 03:22:33.415: E/AndroidRuntime(706):  at com.example.devicecontrolpanel.TestActivity$DeviceSearcher.doInBackground(TestActivity.java:1)
05-23 03:22:33.415: E/AndroidRuntime(706):  at android.os.AsyncTask$2.call(AsyncTask.java:264)
05-23 03:22:33.415: E/AndroidRuntime(706):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
05-23 03:22:33.415: E/AndroidRuntime(706):  ... 5 more

コードが大きすぎるので、その一部を投稿しています。

if(!set.getCheckComputer() && !set.getCheckFlyport() && !set.getCheckRaspberry())
            executed(); //Line number: 289

public void executed()
    {
        DataBaseAdapter db = new DataBaseAdapter(getApplicationContext());
        List<DeviceInformation> oldDevices;
        if(deviceList.size()>0)
            oldDevices = db.getNotAllDevices(deviceList);
        else
            oldDevices = null;
        if(oldDevices!=null)
        {
            ...
            ...
        }
        else
        {
            TableRow tr = new TableRow(getApplicationContext());
            tr.setLayoutParams(layoutParam);
            TextView tv = new TextView(getApplicationContext());
            tv.setTextSize(17);
            tv.setLayoutParams(layoutParam);
            if(rowCounter!=0)
                tv.setText("No device were added before");
            tv.setVisibility(View.VISIBLE);
            tv.setTextColor(Color.WHITE);
            tr.addView(tv);
            tr.setBackgroundColor(Color.BLACK);
            tr.setVisibility(View.VISIBLE);
            deviceTable.addView(tr);
            Toast.makeText(getApplicationContext(), "No Devices Found", Toast.LENGTH_LONG).show();
                            //Error in above line
        }
    }
4

1 に答える 1