I use webVIew read local HTML. HTML storage location Project for asset
Some phones can be successfully used(samsung...) Some phones can not(HTC nexus...)
Here is my code
public class MainActivity extends Activity {
private WebView wvBrowser;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
findViews();
}
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (wvBrowser.canGoBack() && event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
wvBrowser.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
private void findViews() {
wvBrowser = (WebView) findViewById(R.id.Browser);
//wvBrowser.loadUrl(getString(R.string.googleUrl));
wvBrowser.getSettings().setSupportZoom(true);
wvBrowser.getSettings().setBuiltInZoomControls(true);
wvBrowser.loadUrl("file:///android_asset/ts.htm");
}
}
Just wanted to add one more answer. Someone might find my suggestion helpful. You need to add uses-permission in your AndroidManifest.xml. I got similar error fixed by adding this line
<uses-permission android:name="android.permission.INTERNET" />
Try this link it will help you better webview
Attach a WebViewClient to your WebView, where you override onReceivedError()
webview.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With