How to make a loading screen while doing a huge process

508 views Asked by At

i want to make a loading screen while the android app is doing a huge process like finding prime numbers in a range.it takes a long time for the process to done and i want to appear a loading screen or progress bar while it is doing the huge process. here are the codes of my app:

1

There are 1 answers

0
blank_space On

You can add a simple ProgressDialog.

ProgressDialog progress = new ProgressDialog(this);
progress.setTitle("Loading..");
progress.setMessage("Please wait...");
progress.setCancelable(true);

when you need to start it, call

progress.show();

when you need to dismiss it, call

progress.dismiss();