Opening a webpage in an Android app

I was wondering what you guys / gals would recommend in terms of opening a webpage inside the application (i.e. a smaller window with a webpage open in it, but not with a web browser). I am trying to integrate my webpage into my application more or less. Thanks:)

+7
java android webpage
source share
2 answers

Have you tried using the webview layout?

In your layout file:

<?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" /> 

Include the INTERNET permission in your manifest:

 <uses-permission android:name="android.permission.INTERNET" /> 

And then in your activity:

 WebView myWebView = (WebView) findViewById(R.id.webview); myWebView.loadUrl("http://www.example.com"); 

This will add a web browser to your application (rather than opening an external browser).

+8
source share

You can place a view group and then put the web view inside and resize as needed

 <LinearLayout android:orientation="vertical" android:gravity="center" android:layout_width="match_parent" android:layout_height="wrap_content"> <WebView android:id="@+id/webView" android:layout_width="fill_parent" android:layout_height="fill_parent"> </WebView> </LinearLayout> 

In the manifest file, specify permission

 <uses-permission android:name="android.permission.INTERNET" /> 

then you get the object from the code

 WebView myWebView = (WebView) findViewById(R.id.webview); myWebView.loadUrl("http://www.google.com"); 
+1
source share

All Articles