Skip to content Skip to sidebar Skip to footer

Start An Activity From The Thread

I have a class which generates a pdf file. This class is extended by Activity that means is have onCreate, onPause (and so on) methods. While a pdf file is generating it takes som

Solution 1:

Change your code as for starting an Activity from Thread using runOnUiThread:

///... your code here..

    new Thread(new Runnable() {

        @Override
        public void run() {

            Your_Current_Activity.this.runOnUiThread(new Runnable() {

                @Override
                public void run() {

                dialog.cancel();

                // START ACTIVITY HERE
               Your_Current_Activity.this.startActivity(new 
                        Intent(Your_Current_Activity.this,
                                       PdfGenerator.class));

                }
            });

        }

    }).start();

Post a Comment for "Start An Activity From The Thread"