Web Learners, This blog is gonna give you huge knowledge about Mobile App Development, Game development, Internet Marketing, Social Network Marketing, Search Engine Optimization (SEO) ,Mobile Marketing, and website and web application Code knowledge such as HTML, CSS, JavaScript etc. This site is also gonna give you free tools and software with installation guides. Most important Tips and tricks about marketing, software installation and Coding is always available.
As we will show Exit dialog in MainActivity.java, so we will set a function onBackPressed().In that onBackPressed() function we will take an if-else condition.
Code:
The "if" condition will be if our website or app can go back then it will go to the previous page, else it will show Exit dialog. And in the exit dialog, there will be a message, such as "Do you want to Exit?" or anything you want to show to your users.
And there will also two buttons in the Exit dialog, One is the "Yes" button, another one is the "No" Button. Then we have to set "OnClickListener" on "Yes" and "No" both button. In that OnClickListener, we will define what will happen after the user clicks on buttons.
After that, we will set if the user clicks on the "yes" button app will Exit successfully. And if the users click on the "No" button the user will stay on the current page. Then have to show the alert dialog.
So all the code together will be:
Code:
Now you can run your project. You can see below the image we have successfully added Exit dialog on Home Screen. Exit dialog working perfectly.
I am nothing but a online business man. more than 12 years of experiences in online business. I have learned everything of my own. You know if you learn something from your own you will learn more than somebody taught you on that topic. Long story short, I did lots of experiments, did lots of online jobs for the people, got lots of errors changes the way again and again. At the end got the perfect knowledge about online business. I would love to let you know all of my 12 years of knowledge about online business. Keep in touch with the blog to be knowledged about online business.
Thanks
, click here →
bidvertiser
About Site
WebLearners is a blog to teach online business such as E-com Business, App Business, SEO Business, Digital Marketing, etc. Lots of free tools and web applications will be given for free. Actually, We will dig deep on every topic one by one. It will be a long journey but in the end, you will be a succesful online businessman. Tutorials are expressed as a guideline for the person who wishes to start an online business. Readers can ask any questions or can ask for help to develop their business. We will be happy to help.
, click here →
How to Enable Download in Android Webview App? In the Last post of our Webview Series, I have shown How to Add Splash Screen in Any Androi...
bidvertiser
About Me
I am nothing but a online business man. more than 12 years of experiences in online business. I have learned everything of my own. You know if you learn something from your own you will learn more than somebody taught you on that topic. Long story short, I did lots of experiments, did lots of online jobs for the people, got lots of errors changes the way again and again. At the end got the perfect knowledge about online business. I would love to let you know all of my 12 years of knowledge about online business. Keep in touch with the blog to be knowledged about online business.
Thanks
, click here →
No comments:
Post a Comment