Home Getting error while executing AsyncTask in Android App
Reply: 0

Getting error while executing AsyncTask in Android App

user4598
1#
user4598 Published in April 22, 2018, 12:50 am

I am Getting an error java.lang.RuntimeException: An error occurred while executing doInBackground() while executing

here is my doInBackground() method

 @Override
    protected String doInBackground(String... strings) {


            AlertDialog.Builder rewardedAdvert = new AlertDialog.Builder(PlayGame.this);
            View rView = getLayoutInflater().inflate(R.layout.rewardedads, null);
            homeButton = (Button) rView.findViewById(R.id.homebutton);


            homeButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {

                    gameOver();
                }
            });
            rewardedAdvert.setView(rView);

            AlertDialog dialog = rewardedAdvert.create();
          dialog.getWindow().setLayout(700, 700);


        return null;
    }

here is the method where i am calling AsyncTask

  private void wrongAnswer() {
    correctImg.setVisibility(View.INVISIBLE);
    wrongImg.setVisibility(View.VISIBLE);
    ((LightQuiz) this.getApplicationContext()).soundHandler.playWrongSound();
    lives--;
    if (lives == 0) {

       new GameOverRewardedAds().execute();

      //  gameOver();




    }

here is the logcat:

Java.lang.RuntimeException: An error occurred while executing doInBackground()
                                                                            at android.os.AsyncTask$3.done(AsyncTask.java:309)
                                                                            at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
                                                                            at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
                                                                            at java.util.concurrent.FutureTask.run(FutureTask.java:242)
                                                                            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
                                                                            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
                                                                            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                                                                            at java.lang.Thread.run(Thread.java:818)
                                                                         Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
                                                                            at android.os.Handler.<init>(Handler.java:200)
                                                                            at android.os.Handler.<init>(Handler.java:114)
                                                                            at android.app.Dialog.<init>(Dialog.java:119)
                                                                            at android.app.AlertDialog.<init>(AlertDialog.java:200)
                                                                            at android.app.AlertDialog$Builder.create(AlertDialog.java:1086)
                                                                            at com.awwalsoft.javaplay.PlayGame$GameOverRewardedAds.doInBackground(PlayGame.java:429)
                                                                            at com.awwalsoft.javaplay.PlayGame$GameOverRewardedAds.doInBackground(PlayGame.java:387)
                                                                            at android.os.AsyncTask$2.call(AsyncTask.java:295)
                                                                            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
                                                                            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
                                                                            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
                                                                            at java.lang.Thread.run(Thread.java:818) 
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.242153 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO