App activity delay's at opening for first time on navigation drawer












2















I'm facing a problem with an activity of my navigation drawer.When i open this activity
for the first time
it has a delay 1-2 seconds and when i open it again it's getting better(not perfect but better).Is it because it's importing an other API maybe?I've added an asynctask but still nothing.



Here is the code of this activity



public class ImportAPI extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener{
public TextView fullnameside, emailside;

public static String stravaToken;

public static ImageButton btnStrava;
public ImageView tickStrava;

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.importapi);


Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
toolbar.setTitle("");
toolbar.setSubtitle("");

DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();

NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
View headerView = navigationView.getHeaderView(0);
fullnameside = (TextView) headerView.findViewById(R.id.fullnameside);
emailside = (TextView) headerView.findViewById(R.id.emailside);
fullnameside.setText(""+GetInfo.fullname);
emailside.setText(""+GetInfo.email);

navigationView.setNavigationItemSelectedListener(this);
navigationView.getMenu().getItem(3).setChecked(true);

//STRAVA
tickStrava=(ImageView) findViewById(R.id.tickStrava);
btnStrava=(ImageButton) findViewById(R.id.stravaBtn);
new connectStrava().execute("start");

}

@SuppressLint("StaticFieldLeak")
class connectStrava extends AsyncTask<String, String, String> {

@Override
protected void onPreExecute() {
super.onPreExecute();
btnStrava.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent getStravaApi= new Intent(ImportAPI.this,StravaSetupApi.class);
startActivity(getStravaApi);
}
});

//GET ACCESS TOKEN FROM STRAVAS AUTHORIZE ACCOUNT
String accessToken = StravaAuthenticateActivity.getStravaAccessToken(ImportAPI.this);
stravaToken=accessToken; //make static var so i can use it anywhere i want

//Get athletes activities from GetStravaAthleteActivities.java
new GetStravaAthleteActivities.AthleteActivities();

//check if token is null so i can display the tick and also disable the button press
if(stravaToken!=null)
{
btnStrava.setEnabled(false);
tickStrava.setVisibility(View.VISIBLE);
}
else {
tickStrava.setVisibility(View.INVISIBLE);
}
}

@Override
protected String doInBackground(String... aurl) {
Log.d("Alekos","TAK4");
return null;

}
protected void onProgressUpdate(String... progress) {

Log.d("ANDRO_ASYNC",progress[0]);

}

@Override
protected void onPostExecute(String unused) {
}

}









share|improve this question























  • Are you using a high resolution image in that activity layout?

    – Athira
    Nov 14 '18 at 9:13
















2















I'm facing a problem with an activity of my navigation drawer.When i open this activity
for the first time
it has a delay 1-2 seconds and when i open it again it's getting better(not perfect but better).Is it because it's importing an other API maybe?I've added an asynctask but still nothing.



Here is the code of this activity



public class ImportAPI extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener{
public TextView fullnameside, emailside;

public static String stravaToken;

public static ImageButton btnStrava;
public ImageView tickStrava;

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.importapi);


Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
toolbar.setTitle("");
toolbar.setSubtitle("");

DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();

NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
View headerView = navigationView.getHeaderView(0);
fullnameside = (TextView) headerView.findViewById(R.id.fullnameside);
emailside = (TextView) headerView.findViewById(R.id.emailside);
fullnameside.setText(""+GetInfo.fullname);
emailside.setText(""+GetInfo.email);

navigationView.setNavigationItemSelectedListener(this);
navigationView.getMenu().getItem(3).setChecked(true);

//STRAVA
tickStrava=(ImageView) findViewById(R.id.tickStrava);
btnStrava=(ImageButton) findViewById(R.id.stravaBtn);
new connectStrava().execute("start");

}

@SuppressLint("StaticFieldLeak")
class connectStrava extends AsyncTask<String, String, String> {

@Override
protected void onPreExecute() {
super.onPreExecute();
btnStrava.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent getStravaApi= new Intent(ImportAPI.this,StravaSetupApi.class);
startActivity(getStravaApi);
}
});

//GET ACCESS TOKEN FROM STRAVAS AUTHORIZE ACCOUNT
String accessToken = StravaAuthenticateActivity.getStravaAccessToken(ImportAPI.this);
stravaToken=accessToken; //make static var so i can use it anywhere i want

//Get athletes activities from GetStravaAthleteActivities.java
new GetStravaAthleteActivities.AthleteActivities();

//check if token is null so i can display the tick and also disable the button press
if(stravaToken!=null)
{
btnStrava.setEnabled(false);
tickStrava.setVisibility(View.VISIBLE);
}
else {
tickStrava.setVisibility(View.INVISIBLE);
}
}

@Override
protected String doInBackground(String... aurl) {
Log.d("Alekos","TAK4");
return null;

}
protected void onProgressUpdate(String... progress) {

Log.d("ANDRO_ASYNC",progress[0]);

}

@Override
protected void onPostExecute(String unused) {
}

}









share|improve this question























  • Are you using a high resolution image in that activity layout?

    – Athira
    Nov 14 '18 at 9:13














2












2








2








I'm facing a problem with an activity of my navigation drawer.When i open this activity
for the first time
it has a delay 1-2 seconds and when i open it again it's getting better(not perfect but better).Is it because it's importing an other API maybe?I've added an asynctask but still nothing.



Here is the code of this activity



public class ImportAPI extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener{
public TextView fullnameside, emailside;

public static String stravaToken;

public static ImageButton btnStrava;
public ImageView tickStrava;

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.importapi);


Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
toolbar.setTitle("");
toolbar.setSubtitle("");

DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();

NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
View headerView = navigationView.getHeaderView(0);
fullnameside = (TextView) headerView.findViewById(R.id.fullnameside);
emailside = (TextView) headerView.findViewById(R.id.emailside);
fullnameside.setText(""+GetInfo.fullname);
emailside.setText(""+GetInfo.email);

navigationView.setNavigationItemSelectedListener(this);
navigationView.getMenu().getItem(3).setChecked(true);

//STRAVA
tickStrava=(ImageView) findViewById(R.id.tickStrava);
btnStrava=(ImageButton) findViewById(R.id.stravaBtn);
new connectStrava().execute("start");

}

@SuppressLint("StaticFieldLeak")
class connectStrava extends AsyncTask<String, String, String> {

@Override
protected void onPreExecute() {
super.onPreExecute();
btnStrava.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent getStravaApi= new Intent(ImportAPI.this,StravaSetupApi.class);
startActivity(getStravaApi);
}
});

//GET ACCESS TOKEN FROM STRAVAS AUTHORIZE ACCOUNT
String accessToken = StravaAuthenticateActivity.getStravaAccessToken(ImportAPI.this);
stravaToken=accessToken; //make static var so i can use it anywhere i want

//Get athletes activities from GetStravaAthleteActivities.java
new GetStravaAthleteActivities.AthleteActivities();

//check if token is null so i can display the tick and also disable the button press
if(stravaToken!=null)
{
btnStrava.setEnabled(false);
tickStrava.setVisibility(View.VISIBLE);
}
else {
tickStrava.setVisibility(View.INVISIBLE);
}
}

@Override
protected String doInBackground(String... aurl) {
Log.d("Alekos","TAK4");
return null;

}
protected void onProgressUpdate(String... progress) {

Log.d("ANDRO_ASYNC",progress[0]);

}

@Override
protected void onPostExecute(String unused) {
}

}









share|improve this question














I'm facing a problem with an activity of my navigation drawer.When i open this activity
for the first time
it has a delay 1-2 seconds and when i open it again it's getting better(not perfect but better).Is it because it's importing an other API maybe?I've added an asynctask but still nothing.



Here is the code of this activity



public class ImportAPI extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener{
public TextView fullnameside, emailside;

public static String stravaToken;

public static ImageButton btnStrava;
public ImageView tickStrava;

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.importapi);


Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
toolbar.setTitle("");
toolbar.setSubtitle("");

DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();

NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
View headerView = navigationView.getHeaderView(0);
fullnameside = (TextView) headerView.findViewById(R.id.fullnameside);
emailside = (TextView) headerView.findViewById(R.id.emailside);
fullnameside.setText(""+GetInfo.fullname);
emailside.setText(""+GetInfo.email);

navigationView.setNavigationItemSelectedListener(this);
navigationView.getMenu().getItem(3).setChecked(true);

//STRAVA
tickStrava=(ImageView) findViewById(R.id.tickStrava);
btnStrava=(ImageButton) findViewById(R.id.stravaBtn);
new connectStrava().execute("start");

}

@SuppressLint("StaticFieldLeak")
class connectStrava extends AsyncTask<String, String, String> {

@Override
protected void onPreExecute() {
super.onPreExecute();
btnStrava.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent getStravaApi= new Intent(ImportAPI.this,StravaSetupApi.class);
startActivity(getStravaApi);
}
});

//GET ACCESS TOKEN FROM STRAVAS AUTHORIZE ACCOUNT
String accessToken = StravaAuthenticateActivity.getStravaAccessToken(ImportAPI.this);
stravaToken=accessToken; //make static var so i can use it anywhere i want

//Get athletes activities from GetStravaAthleteActivities.java
new GetStravaAthleteActivities.AthleteActivities();

//check if token is null so i can display the tick and also disable the button press
if(stravaToken!=null)
{
btnStrava.setEnabled(false);
tickStrava.setVisibility(View.VISIBLE);
}
else {
tickStrava.setVisibility(View.INVISIBLE);
}
}

@Override
protected String doInBackground(String... aurl) {
Log.d("Alekos","TAK4");
return null;

}
protected void onProgressUpdate(String... progress) {

Log.d("ANDRO_ASYNC",progress[0]);

}

@Override
protected void onPostExecute(String unused) {
}

}






android navigation-drawer delay






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 9:06









Alex KolydasAlex Kolydas

334114




334114













  • Are you using a high resolution image in that activity layout?

    – Athira
    Nov 14 '18 at 9:13



















  • Are you using a high resolution image in that activity layout?

    – Athira
    Nov 14 '18 at 9:13

















Are you using a high resolution image in that activity layout?

– Athira
Nov 14 '18 at 9:13





Are you using a high resolution image in that activity layout?

– Athira
Nov 14 '18 at 9:13












2 Answers
2






active

oldest

votes


















3














I think you are doing some blocking task in onPreexecute() of your AsyncTask.
pls modify your AsyncTask as below.



class connectStrava extends AsyncTask<String, String, String> {

@Override
protected void onPreExecute() {
super.onPreExecute();
btnStrava.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent getStravaApi= new Intent(ImportAPI.this,StravaSetupApi.class);
startActivity(getStravaApi);
}
});




}

@Override
protected String doInBackground(String... aurl) {
//GET ACCESS TOKEN FROM STRAVAS AUTHORIZE ACCOUNT
String accessToken = StravaAuthenticateActivity.getStravaAccessToken(ImportAPI.this);
stravaToken=accessToken; //make static var so i can use it anywhere i want

//Get athletes activities from GetStravaAthleteActivities.java
new GetStravaAthleteActivities.AthleteActivities();
return stravaToken;

}
protected void onProgressUpdate(String... progress) {

Log.d("ANDRO_ASYNC",progress[0]);

}

@Override
protected void onPostExecute(String result) {
//check if token is null so i can display the tick and also disable the button press
if(stravaToken!=null)
{
btnStrava.setEnabled(false);
tickStrava.setVisibility(View.VISIBLE);
}
else {
tickStrava.setVisibility(View.INVISIBLE);
}
}


}






share|improve this answer































    2















    FYI




    btnStrava.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
    Intent getStravaApi= new Intent(ImportAPI.this,StravaSetupApi.class);
    startActivity(getStravaApi);
    }
    });


    This code is not required to be kept inside onPreExecute() keep it inside of onCreate()




    You are calling API in the start which is actually not delay but the
    time it is taking for the API calling.



    Use ProgressBar untill your AsyncTask gets completed.







    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53296437%2fapp-activity-delays-at-opening-for-first-time-on-navigation-drawer%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      3














      I think you are doing some blocking task in onPreexecute() of your AsyncTask.
      pls modify your AsyncTask as below.



      class connectStrava extends AsyncTask<String, String, String> {

      @Override
      protected void onPreExecute() {
      super.onPreExecute();
      btnStrava.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
      Intent getStravaApi= new Intent(ImportAPI.this,StravaSetupApi.class);
      startActivity(getStravaApi);
      }
      });




      }

      @Override
      protected String doInBackground(String... aurl) {
      //GET ACCESS TOKEN FROM STRAVAS AUTHORIZE ACCOUNT
      String accessToken = StravaAuthenticateActivity.getStravaAccessToken(ImportAPI.this);
      stravaToken=accessToken; //make static var so i can use it anywhere i want

      //Get athletes activities from GetStravaAthleteActivities.java
      new GetStravaAthleteActivities.AthleteActivities();
      return stravaToken;

      }
      protected void onProgressUpdate(String... progress) {

      Log.d("ANDRO_ASYNC",progress[0]);

      }

      @Override
      protected void onPostExecute(String result) {
      //check if token is null so i can display the tick and also disable the button press
      if(stravaToken!=null)
      {
      btnStrava.setEnabled(false);
      tickStrava.setVisibility(View.VISIBLE);
      }
      else {
      tickStrava.setVisibility(View.INVISIBLE);
      }
      }


      }






      share|improve this answer




























        3














        I think you are doing some blocking task in onPreexecute() of your AsyncTask.
        pls modify your AsyncTask as below.



        class connectStrava extends AsyncTask<String, String, String> {

        @Override
        protected void onPreExecute() {
        super.onPreExecute();
        btnStrava.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
        Intent getStravaApi= new Intent(ImportAPI.this,StravaSetupApi.class);
        startActivity(getStravaApi);
        }
        });




        }

        @Override
        protected String doInBackground(String... aurl) {
        //GET ACCESS TOKEN FROM STRAVAS AUTHORIZE ACCOUNT
        String accessToken = StravaAuthenticateActivity.getStravaAccessToken(ImportAPI.this);
        stravaToken=accessToken; //make static var so i can use it anywhere i want

        //Get athletes activities from GetStravaAthleteActivities.java
        new GetStravaAthleteActivities.AthleteActivities();
        return stravaToken;

        }
        protected void onProgressUpdate(String... progress) {

        Log.d("ANDRO_ASYNC",progress[0]);

        }

        @Override
        protected void onPostExecute(String result) {
        //check if token is null so i can display the tick and also disable the button press
        if(stravaToken!=null)
        {
        btnStrava.setEnabled(false);
        tickStrava.setVisibility(View.VISIBLE);
        }
        else {
        tickStrava.setVisibility(View.INVISIBLE);
        }
        }


        }






        share|improve this answer


























          3












          3








          3







          I think you are doing some blocking task in onPreexecute() of your AsyncTask.
          pls modify your AsyncTask as below.



          class connectStrava extends AsyncTask<String, String, String> {

          @Override
          protected void onPreExecute() {
          super.onPreExecute();
          btnStrava.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
          Intent getStravaApi= new Intent(ImportAPI.this,StravaSetupApi.class);
          startActivity(getStravaApi);
          }
          });




          }

          @Override
          protected String doInBackground(String... aurl) {
          //GET ACCESS TOKEN FROM STRAVAS AUTHORIZE ACCOUNT
          String accessToken = StravaAuthenticateActivity.getStravaAccessToken(ImportAPI.this);
          stravaToken=accessToken; //make static var so i can use it anywhere i want

          //Get athletes activities from GetStravaAthleteActivities.java
          new GetStravaAthleteActivities.AthleteActivities();
          return stravaToken;

          }
          protected void onProgressUpdate(String... progress) {

          Log.d("ANDRO_ASYNC",progress[0]);

          }

          @Override
          protected void onPostExecute(String result) {
          //check if token is null so i can display the tick and also disable the button press
          if(stravaToken!=null)
          {
          btnStrava.setEnabled(false);
          tickStrava.setVisibility(View.VISIBLE);
          }
          else {
          tickStrava.setVisibility(View.INVISIBLE);
          }
          }


          }






          share|improve this answer













          I think you are doing some blocking task in onPreexecute() of your AsyncTask.
          pls modify your AsyncTask as below.



          class connectStrava extends AsyncTask<String, String, String> {

          @Override
          protected void onPreExecute() {
          super.onPreExecute();
          btnStrava.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
          Intent getStravaApi= new Intent(ImportAPI.this,StravaSetupApi.class);
          startActivity(getStravaApi);
          }
          });




          }

          @Override
          protected String doInBackground(String... aurl) {
          //GET ACCESS TOKEN FROM STRAVAS AUTHORIZE ACCOUNT
          String accessToken = StravaAuthenticateActivity.getStravaAccessToken(ImportAPI.this);
          stravaToken=accessToken; //make static var so i can use it anywhere i want

          //Get athletes activities from GetStravaAthleteActivities.java
          new GetStravaAthleteActivities.AthleteActivities();
          return stravaToken;

          }
          protected void onProgressUpdate(String... progress) {

          Log.d("ANDRO_ASYNC",progress[0]);

          }

          @Override
          protected void onPostExecute(String result) {
          //check if token is null so i can display the tick and also disable the button press
          if(stravaToken!=null)
          {
          btnStrava.setEnabled(false);
          tickStrava.setVisibility(View.VISIBLE);
          }
          else {
          tickStrava.setVisibility(View.INVISIBLE);
          }
          }


          }







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 14 '18 at 9:14









          ManishManish

          4091620




          4091620

























              2















              FYI




              btnStrava.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
              Intent getStravaApi= new Intent(ImportAPI.this,StravaSetupApi.class);
              startActivity(getStravaApi);
              }
              });


              This code is not required to be kept inside onPreExecute() keep it inside of onCreate()




              You are calling API in the start which is actually not delay but the
              time it is taking for the API calling.



              Use ProgressBar untill your AsyncTask gets completed.







              share|improve this answer




























                2















                FYI




                btnStrava.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                Intent getStravaApi= new Intent(ImportAPI.this,StravaSetupApi.class);
                startActivity(getStravaApi);
                }
                });


                This code is not required to be kept inside onPreExecute() keep it inside of onCreate()




                You are calling API in the start which is actually not delay but the
                time it is taking for the API calling.



                Use ProgressBar untill your AsyncTask gets completed.







                share|improve this answer


























                  2












                  2








                  2








                  FYI




                  btnStrava.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                  Intent getStravaApi= new Intent(ImportAPI.this,StravaSetupApi.class);
                  startActivity(getStravaApi);
                  }
                  });


                  This code is not required to be kept inside onPreExecute() keep it inside of onCreate()




                  You are calling API in the start which is actually not delay but the
                  time it is taking for the API calling.



                  Use ProgressBar untill your AsyncTask gets completed.







                  share|improve this answer














                  FYI




                  btnStrava.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                  Intent getStravaApi= new Intent(ImportAPI.this,StravaSetupApi.class);
                  startActivity(getStravaApi);
                  }
                  });


                  This code is not required to be kept inside onPreExecute() keep it inside of onCreate()




                  You are calling API in the start which is actually not delay but the
                  time it is taking for the API calling.



                  Use ProgressBar untill your AsyncTask gets completed.








                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 14 '18 at 9:19









                  Vir RajpurohitVir Rajpurohit

                  801312




                  801312






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53296437%2fapp-activity-delays-at-opening-for-first-time-on-navigation-drawer%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      這個網誌中的熱門文章

                      Hercules Kyvelos

                      Tangent Lines Diagram Along Smooth Curve

                      Yusuf al-Mu'taman ibn Hud