Categories

Follow Us @web_learners

Monday, April 6, 2020

How to Add Exit Dialog on Splash Screen In Webview Android App | Webview App Development Series Part 8

Hi, Today I will show you How to Add Exit Dialog In Webview Android App. In the previous post I have shown you How to Add Pull to Refresh in Webview App. you can check it out. By the way Let's start.



As In my app has Splash Screen, so I will implement App Exit dialog in my SplashActivity.java file.
I will write a function called onBackPressed below the "onCreate" and will set a Message for showing the user when the user will want to exit the app.

And there will be two buttons, one is "Yes" button, another one is the "No" button. If the user clicks on the "Yes" button, Webview App will exit.  and if the user clicks on the "No" button, the user will stay the current page.


Code:



So, the whole code will be in SplashActivity.java is :


Code:

And the whole code will be in activity_splash.xml is:

Code:



That's it. We have finished coding. now we will run our webview project.


As you can see in my screenshot above, It's working perfectly. Thanks.

No comments:

Post a Comment