java - Embedding a Web page in an Android App -
java - Embedding a Web page in an Android App -
i trying embed webpage within android app. next code written in main_activity java file of app.
package com.example.webpage; import android.support.v7.app.actionbaractivity; import android.os.bundle; import android.view.menu; import android.view.menuitem; import android.webkit.webview; public class mainactivity extends actionbaractivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); webview webview = new webview(this); setcontentview(webview); webview.loadurl("http://www.google.com/"); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); homecoming true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action bar // automatically handle clicks on home/up button, long // specify parent activity in androidmanifest.xml. int id = item.getitemid(); if (id == r.id.action_settings) { homecoming true; } homecoming super.onoptionsitemselected(item); } }
the problem whenever launched app in emulator shows me "page not found" error. please help me out.
try in way first take webview in xml bind them webview webview = (webview)findviewbyid(r.id.webview1);
then seek following
string url = "http://www.google.com/"; webview webview = (webview)findviewbyid(r.id.webview1); webview.getsettings().setjavascriptenabled(true); webview.loadurl(url);
java android xml android-emulator webpage
Comments
Post a Comment