0

thanks you for help i cleared this using volley liabraries. I have a app in which there are 12 AsyncTask, which are used to downloa data from server. I want to navigate to next activity on button click. When user click on button i am stopping or cancelling all AsyncTask, but this process leads to lagging or hang screen for 5 to 10 second before proceeding to next activity. According to me, this is happening,because it is cancelling AsyncTask.Is there any better way to switch activity? i am swiching successfuly but hanging for some time.

android_jain
  • 788
  • 8
  • 19

2 Answers2

1

Please try writing the code in a separate ui thread as follows:

new Handler().post(new Runnable() {
    @Override
    public void run() {
        // start your new activity here
    }
});
Shahid Sarwar
  • 1,209
  • 14
  • 29
1

Try using background service class, so there won't be any lagging while switching activity.

  • i m using background task ?? any difference between do in background and background service – android_jain Jan 27 '17 at 06:33
  • background task will be associated with the respective activity class, but background service is independent. Even if you finish the class it won't affect your service. – Kevin Kulothungan Jan 27 '17 at 06:49