0

I keep getting this error on this line of code and cannot figure out the root cause

closedialog.show();

I have tried putting a try/catch around it but the error still persists.

Runnable runnable = new Runnable() {
                        @Override
                        public void run() {
                            handler.post(new Runnable() { // This thread runs in the UI
                                @Override
                                public void run() {
                                    try{

                                    AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this);
                                    alert.setTitle("Message");
                                    alert.setMessage(alertMessage);
                                    alert.setIcon(R.drawable.recharge_icon);
                                    //alert.show();
                                    final AlertDialog closedialog= alert.create();
                                    closedialog.show();
                                    final Timer timer2 = new Timer();
                                    timer2.schedule(new TimerTask() {
                                        public void run() {
                                            closedialog.dismiss(); 
                                            timer2.cancel(); //this will cancel the timer of the system
                                        }
                                    }, 8000); // the timer will count 5 seconds....

                                }catch(Exception ex){
                                    ex.printStackTrace();
                                }

                                }   
                           });
                        }
                    };
                    new Thread(runnable).start();
                    return

;

Please what could be wrong?

Blaze
  • 2,269
  • 11
  • 40
  • 82

0 Answers0