[Solved] Why is my app is crashing while using async task?


You are Calling Activity in a Background Thread Thats Why you are getting Error
You Need to Call Like this

    Thread thread=new Thread(){
        @Override
        public void run() {
            try {
                sleep(5*1000);
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Intent i = new Intent(getApplicationContext(),MainActivity2.class);
                        startActivity(i);
                    }
                });

            }
            catch (Exception ex)
            {}
        }
    };
    thread.start();

0

solved Why is my app is crashing while using async task?