javascript - How to send data from activity to a webview in that activity itself? -
from activity sending data activity
public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); final edittext etxt=(edittext)findviewbyid(r.id.edittext1); final edittext etxt1=(edittext)findviewbyid(r.id.edittext2); button btn=(button)findviewbyid(r.id.button1); btn.setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { // todo auto-generated method stub string s= etxt.gettext().tostring(); string s1= etxt1.gettext().tostring(); intent intent= new intent(getapplicationcontext(),webactivity.class); intent.putextra("key", s); intent.putextra("key1", s1); } }); } }
my second activity receive data intent , want display in webview.
public class webactivity extends activity { webview webview; /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.webpage); bundle b = getintent().getextras(); string s = b.getstring("key"); string s1=b.getstring("key1"); webview=(webview)findviewbyid(r.id.webview); }
}
from searching on google found can accomplished using javascript variables dont know how it. kindly answer.
did checked android webview documentation?
// simplest usage: note exception not thrown // if there error loading page (see below). webview.loadurl("http://slashdot.org/"); // or, can load html string: string summary = "<html><body>you scored <b>192</b> points.</body></html>"; webview.loaddata(summary, "text/html", null); // ... although note there restrictions on html can do. // see javadocs loaddata() , loaddatawithbaseurl() more info.
Comments
Post a Comment