Vinoth Vinoth - 12 days ago 4x
Android Question

Android webview back button

In my app when user clicks on a gallery widget i open the image in a webview as it supports zoom functionality.

Now when user clicks back button on webview i want the user to see my application. But it goes directly to home screen.

How should i handle the onBackKeyPressed() ?


Override the Activity's onKeyDown(..) event

public boolean onKeyDown(int keyCode, KeyEvent event) {

    if (keyCode == KeyEvent.KEYCODE_BACK) {
        // close image gallery
        return false; // this avoids passing to super

    return super.onKeyDown(keyCode, event);

*edit: code