Reputation:
I have a startup activity, this is a launcher activity, in this I have intent for the sliding activity this is to show the walk through screens.
Now When I run the app it takes few seconds to start the sliding activity. I want to show a progress dialog till the sliding activity starts.
How can I do this?
StartUp activity:
public class StartUpActivity extends AppCompatActivity{
boolean isUserFirstTime,login;
public static String PREF_USER_FIRST_TIME;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
isUserFirstTime = Boolean.valueOf(Utils.readSharedSetting(StartUpActivity.this, PREF_USER_FIRST_TIME, "true"));
Intent introIntent = new Intent(StartUpActivity.this, SlidingActivity.class);
introIntent.putExtra(PREF_USER_FIRST_TIME, isUserFirstTime);
ProgressDialog dialog=new ProgressDialog(StartUpActivity.this);
dialog.setMessage("Welcome to Mea Vita, please wait till the app loads.");
dialog.setCancelable(false);
dialog.setInverseBackgroundForced(false);
dialog.show();
startActivity(new Intent(StartUpActivity.this,SlidingActivity.class));
dialog.hide();
}
}
Please help. Thank you.
Upvotes: 1
Views: 989
Reputation: 2514
ok if you want show a dialog for 1 or 2 seconds you can use Handler
class.like
ProgressDialog dialog=new ProgressDialog(StartUpActivity.this);
dialog.setMessage("Welcome to Mea Vita, please wait till the app loads.");
dialog.setCancelable(false);
dialog.setInverseBackgroundForced(false);
dialog.show();
this is as your ProgressDialog
write this code for the delay of 1 second or 2 seconds.
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
//Here you can send the extras.
Intent i = new Intent(this, NextActivity.class);
startActivity(i);
// close this activity
finish();
}
}, 2000);
Upvotes: 1