I was wondering what you guys/gals would recommend in terms of opening a webpage inside an app (i.e a smaller window with a webpage open in it but not a web browser) Im trying to integrate my webpage into my app more or less. Thanks :)
String url = "http://www.example.com"; Intent i = new Intent(Intent. ACTION_VIEW); i. setData(Uri. parse(url)); startActivity(i);
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 into 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 embed a web-browser into your application (rather than open an external browser).
You can place you view group and then place the webview inside and modify size 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 your manifest file give the permission
<uses-permission android:name="android.permission.INTERNET" />
then you get the object from code
WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.loadUrl("http://www.google.com");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With