How To Setup Android WebView To Make It Work Identically Android Browser?
Solution 1:
If you want to use a webview with exactly the same features as the native android browser, you have to check MANY options and settings. A WebView is made to NOT use all of the browsers options and settings for better performance and for having more controll on what the users can and can not do while browsing. to figure out all the opportunities you should read through the api documentation here: http://developer.android.com/reference/android/webkit/WebView.html
For some further dealing and handling with the WebView class also here are some usefull sample codelines: http://pankajchunchun.wordpress.com/2013/01/09/example-of-webview-with-result-handler-and-connection-timeout-handler/
I hope this will help you.
Solution 2:
this is the webview example source..
what kind of setting do you wanna know??
public class MainActivity extends Activity {
WebView webview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webview = (WebView)findViewById(R.id.webview);
webview.setWebViewClient(new WebClient());
WebSettings set = webview.getSettings();
set.setJavaScriptEnabled(true);
set.setBuiltInZoomControls(true);
webview.loadUrl("http://www.google.com");
findViewById(R.id.btnStart).setOnClickListener(onclick);
}
OnClickListener onclick =new OnClickListener() {
@Override
public void onClick(View v) {
String url= null;
EditText add = (EditText)findViewById(R.id.add);
url = add.getText().toString();
webview.loadUrl(url);
}
};
class WebClient extends WebViewClient {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
Solution 3:
In addition to @Ssam's answer, you might want to manage the back button press so your app/Activity doesn't get closed on back press.
@Override
public void onBackPressed() {
if (webview.canGoBack()) {
webview.goBack();
}else
super.onBackPressed();
}
where webview is your webview
Post a Comment for "How To Setup Android WebView To Make It Work Identically Android Browser?"