Android App Development | Lecture#29 | Hive Learners
๐๐ป๐ฎ๐ฎ๐ฝ๐ฒ๐ท๐ฐ๐ผ
Greetings, Dear Hive Learners community member a warm welcome to you in the 29th lecture of the Android App Development series. We have already worked on signing signup and the welcome screen./ But sometimes we just need to show a progress bar to the end user to execute some data in the background. Meanwhile, we will show a progress dialog. We can stop this dialog on task completion or new can show it for specific time intervals.
GitHub Link
Use this GitHub project to clone into your directory. It will constantly get updated in the following lecture so you will never miss the latest code. Happy Coding!.
What Should I Learn
- How to create ProgressDialog
- How to use the Handler
Assignment
- Show a ProgressDialg for 3 seconds.
Procedure
- First, we need to declare and initialize the progress dialog. I am using the Welcome activity for this. We will also set the message that will show in the progress dialog by using its setMessage method. we can also change it later.
I want to show the Progress Dialog for 2 seconds so I am going to use a handler that will run the time and after 2 seconds the ProgressDialog will automatically hide.
Now first we need to show the Progress Dialog and then after 2 seconds, we will cancel it with the help of a handler. We will write the cancel code in the run method of the handler. We also check if the Progress Dialog is on the screen or not. If we do not check it then it can result in some error that we can cancel a progress dialog that is not showing.
progressDialog.show();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (progressDialog.isShowing()) {
progressDialog.cancel();
}
}
}, 2000);
Now let's run the app and check if it is working or not.
Yay! ๐ค
Your content has been boosted with Ecency Points, by @faisalamin.
Use Ecency daily to boost your growth on platform!
Support Ecency
Vote for new Proposal
Delegate HP and earn more
Thanks for another chapter!
!1UP
Click this banner to join "The Cartel" discord server to know more.
You have received a 1UP from @gwajnberg!
@stem-curator
And they will bring !PIZZA ๐.
Learn more about our delegation service to earn daily rewards. Join the Cartel on Discord.
Thank you so much for this edition. I have learnt some new things here
I am happy you find it useful. Thank You