Android back button in an embedded browser webview?

I would like to implement a "soft" back button that always shows up at the top of the embedded browser view This will be pointless in your current implementation. As you state: Now suppose the user navigates one more level by clicking on a link in the browser view. This opens a new browser window Note the key phrase here is "a new browser window", referring to the user's default choice of browser app.

You cannot "implement a 'soft' back button that always shows up at the top of" the user's default choice of browser app. While you could put a Button alongside your WebView that Button will only be visible when the activity containing the WebView is, and there, the user can press the ordinary hardware BACK button to exit that activity But when I use that solution, the android native button also takes you back directly to the prior activity (instead of going back in history of the page) That is because there is only one activity, and the BACK button does not automagically have meaning for an activity with a WebView For example, suppose the activity had two WebViews which one would BACK handle? Is there a way so that I can do both (have a custom back button that takes me back all the way but have the android native back retain the expected behavior of going back one page at a time?

You can override onBackPressed() (or onKeyDown() for pre-Android 2.0) to get control when the hardware BACK key is pressed. You can use that to move back in the WebView history, or if there is no history, allow the normal processing ( finish() ) to occur I would recommend an action bar for allowing users to switch to some other mode of your app. Action bars are part of Honeycomb, and there are open source implementations you can use for earlier versions of Android.

I would like to implement a "soft" back button that always shows up at the top of the embedded browser view. This will be pointless in your current implementation. As you state: Now suppose the user navigates one more level by clicking on a link in the browser view.

This opens a new browser window. Note the key phrase here is "a new browser window", referring to the user's default choice of browser app. You cannot "implement a 'soft' back button that always shows up at the top of" the user's default choice of browser app.

While you could put a Button alongside your WebView, that Button will only be visible when the activity containing the WebView is, and there, the user can press the ordinary hardware BACK button to exit that activity. But when I use that solution, the android native button also takes you back directly to the prior activity (instead of going back in history of the page). That is because there is only one activity, and the BACK button does not automagically have meaning for an activity with a WebView.

For example, suppose the activity had two WebViews -- which one would BACK handle? Is there a way so that I can do both (have a custom back button that takes me back all the way but have the android native back retain the expected behavior of going back one page at a time? You can override onBackPressed() (or onKeyDown() for pre-Android 2.0) to get control when the hardware BACK key is pressed.

You can use that to move back in the WebView history, or if there is no history, allow the normal processing (finish()) to occur. I would recommend an action bar for allowing users to switch to some other mode of your app. Action bars are part of Honeycomb, and there are open source implementations you can use for earlier versions of Android.

Thanx CommonWare. I think you answered most of my question. I would mark this as the correct answer for now.

– serverman Feb 10 at 17:59.

I would like to implement a "soft" back button that always shows up at the top of the embedded browser view. This will be pointless in your current implementation. Now suppose the user navigates one more level by clicking on a link in the browser view.

This opens a new browser window. Note the key phrase here is "a new browser window", referring to the user's default choice of browser app. You cannot "implement a 'soft' back button that always shows up at the top of" the user's default choice of browser app.

While you could put a Button alongside your WebView, that Button will only be visible when the activity containing the WebView is, and there, the user can press the ordinary hardware BACK button to exit that activity. But when I use that solution, the android native button also takes you back directly to the prior activity (instead of going back in history of the page). That is because there is only one activity, and the BACK button does not automagically have meaning for an activity with a WebView.

For example, suppose the activity had two WebViews -- which one would BACK handle? Is there a way so that I can do both (have a custom back button that takes me back all the way but have the android native back retain the expected behavior of going back one page at a time? You can override onBackPressed() (or onKeyDown() for pre-Android 2.0) to get control when the hardware BACK key is pressed.

You can use that to move back in the WebView history, or if there is no history, allow the normal processing (finish()) to occur. I would recommend an action bar for allowing users to switch to some other mode of your app. Action bars are part of Honeycomb, and there are open source implementations you can use for earlier versions of Android.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions