关闭网页视图在android系统 [英] closing webview in android
问题描述
我使用Twitter4j但我需要通过OAuth验证用户。用户需要得到一个别针,并输入到它的应用程序。当我打开一个网页视图URL和用户接受的给应用程序的权限,他们收到一个引脚。他们将如何关闭网页流量,以输入引脚。我不能关闭的WebView在模拟器。下面是其中URL检索后显示在网页视图中的异步类中的方法。
保护无效onPostExecute(字符串URL){ 的WebView的WebView =新的WebView(MainActivity.this);
的setContentView(web视图);
webview.loadUrl(URL);
}
那么,你可以
-
而使用另一个专用活动与主要网页视图[可能也与完成按钮。你可以从你的
onPostExecute
启动该活动意图,然后当用户用它做,你会回去,或者你可以启动的WebView活动的为结果 -
另一种方法是,当你调用
的setContentView
与另一个布局,另一种观点认为完成,例如更换你的WebView。我从来没有这样做有自己,不知道它会很容易的工作,但我发现,一些人建议使用的 ViewFlipper 获得类似的效果。
希望有所帮助。
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 to give the app privileges, they receive a pin. How would they close the webview in order to input the pin. I cant close the webview in the emulator. Below is the method in the Async class where the webview is shown after the url is retrieved.
protected void onPostExecute(String url) {
WebView webview = new WebView(MainActivity.this);
setContentView(webview);
webview.loadUrl(url);
}
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 resultAnother 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.
这篇关于关闭网页视图在android系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!