I'm trying to open a web page inside my newest android app. (I'm following this guide...)


My goal with the app is to open up the web page every time it gets opened, but the web pages need to open within the activity.

With the code below, it does open the web page, but inside the browser app, how can I open the web page inside my own app?

What specific changes do I need to make on my .java activity file, and my .xml layout file?

// part of .java activity file

WebView webview = new WebView(this);


I haven't modified the .xml file, but should I?

Recommended Answers

All 2 Replies

the code that you have given here works.

following is my complete activity

public class WebViewActivity extends Activity {
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        /*Uri uri = Uri.parse("http://www.google.com");
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        WebView webview = new WebView(this);
     // Simplest usage: note that an exception will NOT be thrown
        // if there is an error loading this page (see below).
       // webview.loadUrl("http://slashdot.org/");

        // OR, you can also load from an HTML string:
        String summary = "<html><body>You scored <b>192</b> points.</body></html>";
        webview.loadData(summary, "text/html", null);
        // ... although note that there are restrictions on what this HTML can do.
        // See the JavaDocs for loadData() and loadDataWithBaseURL() for more info.

Thanks very helpful thread, and for those who are new to Android System WebView App which offer web environment integration, see: What Is Android System WebView App? I hope this helps. Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.