Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open Url in webView in android

Tags:

How to open this link in webView. This is running on browser but it does not run in webView android. Please give solution.

like image 246
user8938 Avatar asked Nov 07 '12 11:11

user8938


People also ask

How do I open a link in WebView?

Within the shouldOverrideUrlLoading() method simply get the URL from the request and pass into the Intent. See the full example.

How do I open a link in an Android app?

Every android app will have list of urls that it can open. So you have to go to that app settings and tell that it should open in browser for the urls and not in the app. To do that go to Settings -> Apps -> scroll down to the app that you don't want URLs to open in -> Tap on 'Open by Default' and select always Ask.

How do I open an HTML file in WebView?

Android App Development for Beginners This example demonstrate about How to load html content in android webview. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.


1 Answers

Activity:

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class WebViewActivity extends Activity {

    private WebView webView;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.webview);

        webView = (WebView) findViewById(R.id.webView1);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.loadUrl("http://www.google.com");
    }
}

And your XML:

<?xml version="1.0" encoding="utf-8"?>
<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
/>
like image 152
karmafunk Avatar answered Jan 03 '23 16:01

karmafunk