Reputation: 23
when I press on a Button in my App, I am directed to a new Activity, but this takes a little time and the user might think the App is idle. So I want to have a progressbar or this little circle spinning while the new Activity is loading. The question now, how can I set such a progressbar to the Intent task, so that it fills accordingly to the loading progress?
Thank you!
Upvotes: 0
Views: 253
Reputation: 112
You can give some predefined delay and use any of the UI elements like I used alert dialog for my application, you can use any other element and set the timer appropriately.
final AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity()).setMessage("Please wait you are being redirected");
final AlertDialog alert = dialog.create();
alert.show();
alert.setCancelable(false);
new Handler().postDelayed(new Runnable() {
@Override
public void run()
{
Intent i = new Intent(ctx, MyAccount.class);
startActivity(i);
if (alert.isShowing()) {
alert.dismiss();
}
}
}, 3000);
Upvotes: 1