Android browser unable to open web page -
hello new android , written small app "simple web browser". browser unable open page , it's showing error no network available(web page not available) wifi on , normal browser working on device.
please check code below:: simplebrowser.java
package com.thenewboston.travis; import android.app.activity; import android.os.bundle; import android.text.editable; import android.view.view; import android.view.view.onclicklistener; import android.webkit.webview; import android.widget.button; import android.widget.edittext; public class simplebrowser extends activity implements onclicklistener{ button bgo,bback,bforward,bhistory,brefresh; edittext et; webview wb; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.simplebrowser); bgo = (button)findviewbyid(r.id.go); bback = (button)findviewbyid(r.id.bback); bforward = (button)findviewbyid(r.id.bforward); bhistory = (button)findviewbyid(r.id.bhistory); brefresh = (button)findviewbyid(r.id.brefresh); et = (edittext)findviewbyid(r.id.editaddress); wb = (webview)findviewbyid(r.id.webview); wb.setwebviewclient(new ourviewclient()); bgo.setonclicklistener(this); bback.setonclicklistener(this); bforward.setonclicklistener(this); bhistory.setonclicklistener(this); brefresh.setonclicklistener(this); //wb.loadurl("http://www.gmail.com"); } @override public void onclick(view arg0) { // todo auto-generated method stub switch(arg0.getid()) { case r.id.go: string website = et.gettext().tostring(); wb.loadurl(website); break; case r.id.bback: if(wb.cangoback()) wb.goback(); break; case r.id.bforward: if(wb.cangoforward()) wb.goforward(); break; case r.id.bhistory: wb.clearhistory(); break; case r.id.brefresh: wb.reload(); break; } } }
ourviewclient.java
package com.thenewboston.travis; import android.webkit.webview; import android.webkit.webviewclient; public class ourviewclient extends webviewclient { @override public boolean shouldoverrideurlloading(webview view, string url) { // todo auto-generated method stub view.loadurl(url); return true; } }
and .... manifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.thenewboston.travis" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="10" android:targetsdkversion="17" /> <uses-permission android:name="android.permission.set_wallpaper"/> <uses-permission android:name="android.permission.wake_lock"/> <uses-permission android:name="android.permission.internet"/> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="kcraju" android:theme="@style/apptheme"> <activity android:name="com.thenewboston.travis.splash" android:label="kcraju" android:screenorientation="portrait" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name=".startingpoint" android:label="kcraju" > <intent-filter> <action android:name="com.thenewboston.travis.startingpoint" /> <category android:name="android.intent.category.default" /> </intent-filter> </activity> <activity android:name=".menu" android:label="kcraju" > <intent-filter> <action android:name="com.thenewboston.travis.menu" /> <category android:name="android.intent.category.default" /> </intent-filter> </activity> <activity android:name=".prefs" android:label="kcraju" > <intent-filter> <action android:name="com.thenewboston.travis.prefs" /> <category android:name="android.intent.category.default" /> </intent-filter> </activity> <activity android:name=".about" android:label="kcraju" android:theme="@android:style/theme.dialog" > <intent-filter> <action android:name="com.thenewboston.travis.about" /> <category android:name="android.intent.category.default" /> </intent-filter> </activity> <activity android:name=".textplay" android:label="@string/app_name" > </activity> <activity android:name=".email" android:label="@string/app_name" > </activity> <activity android:name=".camera" android:label="@string/app_name" android:screenorientation="portrait" > </activity> <activity android:name=".data" android:label="@string/app_name" android:screenorientation="portrait" > </activity> <activity android:name=".gfx" android:label="@string/app_name" android:screenorientation="portrait" > </activity> <activity android:name=".gfxsurface" android:label="@string/app_name" android:screenorientation="portrait" > </activity> <activity android:name=".soundstuff" android:label="@string/app_name" android:screenorientation="portrait" > </activity> <activity android:name=".slider" android:label="@string/app_name" android:screenorientation="portrait" > </activity> <activity android:name=".memory" android:label="@string/app_name" android:screenorientation="portrait" > </activity> <activity android:name=".openedclass" android:label="@string/app_name" android:screenorientation="portrait" > </activity> <activity android:name=".tabs" android:label="@string/app_name" android:screenorientation="portrait" > </activity> <activity android:name=".simplebrowser" android:label="@string/app_name" android:screenorientation="portrait" > </activity> </application> </manifest>
we need provide url https suffix loadurl
Comments
Post a Comment