How to close webview image popup on back button press? - java

I have a webview app where I'm displaying images in a full screen popup. But, whenever a user press back button, it goes to previous page without closing it. Where the user intent is to close the popup and view other images. If the pop-up is visible, how to stop going back to previous page, but close the pop up.

You have to define a function in your page which is loaded in WebView. When the back button is pressed, you call that function.
You can look at this link for more information:
Calling JavaScript from Android

Related

after returning back from my second Activity to first Activity on clicking button the whole data is gone

I have two activties:
activity_main,
activity_display
in the main_activity user enters his/her name and presses the toggle button to display.
that takes the user to display_activity page where the result is displayed.
if the user finds that he/she has entered the wrong info they can go back and edit.
here is where the problem starts
after pressing the toggle button - display
it goes to display_activity and displays but when I press "back" button I'm restarting the whole (first) main_activity again... no values are present...
even the toggle button that needs to be set to "reset" is again showing "display".
should i use something else instead of
startActivity(intend1);
i want to resume the (first) activity main not restart everything
Seems like your first activity uses results from second activity. you can use startActivityForResult. Here is a very good answer refer to it.
How to manage startActivityForResult on Android

How to close the app when back pressed from main menu

I build an app. There are so many activities. When clicked on the back button of the phone it supposed to exit from the app when in the `MainActivity` but when clicked on back button it switches between the activities visited recently. I added Intents to switch to the activity I need to switch for every activity except `MainActivity`. Now they are working perfectly but I need my app to exit when clicked on the back button of the phone when in the `MainActivity` and also one thing, I have an **Splash Activity** in my app. I made some apps earlier also and there were one `WebView` app and there are only one Activity. In that app also there were a **Splash Activity** and when clicked on the back button it goes to the splash activity and not exiting the app. Also I need to exit the app when clicked on the button.
Please help me!
God Bless!
This can be achieved using finishAffinity()

Activity starts but I need to minimize to see it

I have a splash screen that is an activity, after 2 seconds it will launch the login activity but the screen remains the same. If I change to home screen and go back to app, the screen updates to the login activity. This is happening recently, before I didn't see this issue. Also I haven't touched anything from the splash screen.
I'm using a Handler with postDelayed.
handler.postDelayed(runnable, 2000);
you are going to splash the screen to the next activity when you write the finish() because you don't want to again open this activity when the user press back press.
The same thing is the log-in screen when the user enters your login details in this time you enter the boolean value in the Sharepreference variable and also finish() login activity.
The next time the user opens the app splash screen will be visible when the splash screen visible you decide the activity through share preference variable data where you are going.

How do I code a button to start out greyed out and disabled until an imageview is populated?

I want to have a button greyed out until the user populates an imageview with a desired image from their phone's gallery. How would I code this to have the button's default state to be greyed out (and disabled) but once an image is showing in the imageview, the button is enabled and no longer greyed-out to the user?
myButton.setEnabled(false); did u try this? this will make your botton look grayed and not listen for click events!!
call myButton.setEnabled(true); if you want to listen for click events an turn your button On
you can also see this link if you want to make a custom button

How to resume from the last screen of the app after the user has pressed home once?

In my app I have a requirement that if the Home button is pressed during the working of app and if the user starts the app from the icon from home screen it must resume from the last activity.
How do I save the last screen history and resume it from the same screen?
The AlwaysRetainTaskState might be what you're looking for.
In your AndroidManifest, in the activity tag, just add
android:alwaysRetainTaskState="true"
Check out following posts:
Android - restore last viewed Activity,
Saving Android Activity state using Save Instance State.

Categories

Resources