Skip to content Skip to sidebar Skip to footer

Closing Webview In Android

I am using Twitter4j but I need to authenticate a user with oAuth. The user needs to get a pin and input it into the app. When I load a webview with the url and the user accept's t

Solution 1:

You can't "close" a WebView. What you could do is hide it. Maybe this solution will shed some light - Hide WebView until JavaScript is done

Solution 2:

Well, you could

  • instead use another dedicated activity with mainly a webview [potentially also with 'done' button]. You could start that activity from your onPostExecute with intent, and then you will go back when user is done with it, or you could start that webview activity for result

  • Another option is to replace your webview when you are done with another view, for example by calling setContentView with another layout. I never did this myself, and not sure it will work easily, but I found that some people recommend using ViewFlipper for similar effect.

Hope that helps.

Solution 3:

Add a close button and on its click set:

webview.setVisibility(View.INVISIBLE);   
webview.loadUrl("");   

You can then reduce the height width of the web view to minimum.

Solution 4:

You can call finish() from anywhere inside the Activity class

Solution 5:

This works for me:

webview.destroy();

Post a Comment for "Closing Webview In Android"