知识的价值不在于占有,而在于使用。这篇文章主要讲述WebView得到致命:jni_android.cc(233)]错误相关的知识,希望能为你提供帮助。
有一些问题我的webView。当用户选择点击网站上的链接时,我使用此解决方案,打开本机whatsapp等信使:
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Log.d(LOG_TAG, "shouldOverrideUrlLoading: " + url);
if (url.contains("tel:")) {
startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse(url)));
return true;
} else if (url.startsWith("whatsapp:")
|| url.startsWith("viber:")
|| url.startsWith("telegram:")) {try {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
} catch (android.content.ActivityNotFoundException e) {
Log.e(LOG_TAG, "Error with " + url + ": " + e.toString());
Toast.makeText(getApplicationContext(), getString(R.string.app_not_install), Toast.LENGTH_SHORT).show();
} catch (Exception q){
q.printStackTrace();
}
return true;
}
if (Uri.parse(url).getHost().equals(URL)) {
// This is my web site, so do not override;
let my WebView load the page
return super.shouldOverrideUrlLoading(view, url);
}
return super.shouldOverrideUrlLoading(view, url);
}
但是,如果我点击“电报”,例如,电报应用程序没有安装在我的设备上,请获取下一个错误。
A/chromium: [FATAL:jni_android.cc(233)] Check failed: false. Please include java exception stack in crash report
W/google-breakpad: ### ### ### ### ### ### ### ### ### ### ### ### ###
W/google-breakpad: Chrome build fingerprint:
W/google-breakpad: 1.0
W/google-breakpad: 1
W/google-breakpad: ### ### ### ### ### ### ### ### ### ### ### ### ###
A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 15585 (moilov.filipapp)
我该怎么办呢?
答案【WebView得到致命(jni_android.cc(233)]错误)】您可以使用以下代码。
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
context = WebviewActivity.this;
mPullRefreshWebView = (PullToRefreshWebView) findViewById(R.id.wv);
mWebView = mPullRefreshWebView.getRefreshableView();
tvError.setVisibility(View.GONE);
mWebView.setVisibility(View.VISIBLE);
mWebView.getSettings().setjavascriptEnabled(true);
mWebView.getSettings().setBuiltInZoomControls(true);
dialog = ProgressDialog.show(context, "", "Please wait,", true);
url = "https://google.co.in";
if (objCommon.isOnline(context)) {
tvError.setVisibility(View.GONE);
mWebView.setVisibility(View.VISIBLE);
mWebView.setWebViewClient(new SampleWebViewClient());
mWebView.loadUrl(url);
} else {
Toast.makeText(context, clsCommon.NETWORK_ERROR_MSG, Toast.LENGTH_SHORT).show();
tvError.setVisibility(View.VISIBLE);
mWebView.setVisibility(View.GONE);
if (dialog.isShowing()) dialog.dismiss();
}tvError.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (objCommon.isOnline(context)) {
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setBuiltInZoomControls(true);
dialog = ProgressDialog.show(context, "", "Please wait,", true);
mWebView.setWebViewClient(new SampleWebViewClient());
mWebView.loadUrl(url);
//setting.setCacheMode(WebSettings.LOAD_CACHE_ONLY);
} else {
Toast.makeText(context, clsCommon.NETWORK_ERROR_MSG, Toast.LENGTH_SHORT).show();
tvError.setVisibility(View.VISIBLE);
mWebView.setVisibility(View.GONE);
if (dialog.isShowing()) dialog.dismiss();
}
}
});
mWebView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
// Activities and WebViews measure progress with different scales.
// The progress meter will automatically disappear when we reach 100%
//setProgress(progress * 1000);
if (progress == 100)
{
if (dialog.isShowing()) dialog.dismiss();
mPullRefreshWebView.onRefreshComplete();
if (objCommon.isOnline(context))
{
tvError.setVisibility(View.GONE);
mWebView.setVisibility(View.VISIBLE);
}
else
{
tvError.setVisibility(View.VISIBLE);
mWebView.setVisibility(View.GONE);
}
}
}@Override
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
//Toast.makeText(context, "test : "+message, Toast.LENGTH_LONG).show();
return super.onJsAlert(view, url, message, result);
}
});
}private class SampleWebViewClient extends WebViewClient
{
private Uri mCapturedImageURI;
private int FILECHOOSER_RESULTCODE=11;
private ValueCallback<
Uri>
mUploadMessage;
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}public void onReceivedError(WebView view, int errorCode, String description, String failingUrl)
{
tvError.setVisibility(View.VISIBLE);
mWebView.setVisibility(View.GONE);
if(dialog.isShowing())dialog.dismiss();
}@Override
public void onPageStarted(WebView view, String url, Bitmap favicon)
{
super.onPageStarted(view, url, favicon);
if(objCommon.isOnline(context))
tvError.setVisibility(View.GONE);
else
tvError.setVisibility(View.VISIBLE);
}@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
if(dialog.isShowing())dialog.dismiss();
}
}
推荐阅读
- 让Facebook登录使用Android Webview
- 在WebView Android应用程序中推送通知
- React Native WebView处理android硬件按钮
- 当URL相似时,Android WebView canGoBack()返回false
- 创建新的Windows Phone App项目(“对象引用未设置为对象的实例”错误(WP8 SDK,VS2012))
- 为商店测试Win Phone 8 App时API错误
- 如何将PayPal sdk与Gradle Android集成
- 无法在Android Studio中构建Release APK
- Android(Paypal Express结帐集成无效)