WebView in Android/Access webview/Loading webview in Android/sample program to load web
Using WebView, we can access the web easily. In order to implement webview, add webview in main.xml
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
Now add some 2 lines of codes in your main activity page
mWebView = (WebView) findViewById(R.id.webview);
mWebView.loadUrl("http://www.google.com");
Then add permission to the manifest file to access internet
<uses-permission android:name="android.permission.INTERNET" />
Run your application..
You can also access Internet by calling intent
Uri uri = Uri.parse("http://www.example.com");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
Comments
Post a Comment