Android Channel is unrecoverably broken and will be disposed!问题解决

来源:互联网 发布:竞价调价软件 编辑:程序博客网 时间:2024/06/16 10:57

大概问题来源:

程序需要webview加载h5界面,但有一个H5界面非常怪,进入界面什么问题也没有,从桌面回来,分享回来也没有问题,但中跳转Activity或者关闭当前webivew的Activity时,就闪退重启了!!!

log:

E/ANDR-PERF-OPTSHANDLER: perf_lock_rel: updated /sys/class/scsi_host/host0/../../../clkscale_enable with 1                          return value 2E/cnss-daemon: Stale or unreachable neighbors, ndm state: 4E/ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ id=421, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED] ]E/ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ id=422, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED] ]E/cnss-daemon: Stale or unreachable neighbors, ndm state: 4E/InputDispatcher: channel '694a7a5 com.cyy.demo/com.cyy.demo.client.main.activity.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!E/InputDispatcher: channel '4ccdb88 com.cyy.demo/com.cyy.demo.client.main.activity.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!E/InputDispatcher: channel 'a704bbf com.cyy.demo/com.cyy.demo.client.quickorder.activity.QuickHandleOrderActivity (server)' ~ Channel is unrecoverably broken and will be disposed!E/InputDispatcher: channel '25d6073 com.cyy.demo/com.cyy.demo.framework.base.CommWebActivity (server)' ~ Channel is unrecoverably broken and will be disposed!E/ANDR-PERF-OPTSHANDLER: perf_lock_rel: updated /sys/class/scsi_host/host0/../../../clkscale_enable with 1                          return value 2


网查一篇,一点也没有帮到解决!!!

然后就考虑换第三方webview了,最终选择了TBS(腾讯浏览服务)

sdk下载:https://x5.tencent.com/tbs/sdk.html#

选择他是因为是中文,不用在github找到还要翻译,其二是因为有jar接入,方便:

最后上代码:

import java.net.MalformedURLException;import java.net.URL;import java.net.URLDecoder;import java.util.List;public class CommWebActivity extends BaseActivity {private WebView mWebView;public static final String KEY_URL = "key_url";public static final String KEY_TITLE = "key_title";public static void openWeb(Context c, String url) {openWeb(c, url, null);}/** *  * @param c *            Context * @param url *            url * @param title *            显示title,当title为""时,自动获取url的title */public static void openWeb(Context c, String url, String title) {if (StringUtil.isEmpty(url)) {return;}Intent intent = new Intent(c, CommWebActivity.class);intent.putExtra(KEY_URL, url);intent.putExtra(KEY_TITLE, title);c.startActivity(intent);}@Overrideprotected void onCreate(Bundle bundle) {super.onCreate(bundle);setContentView(R.layout.activity_web);setLeftText("返回");initView();initData();}public void initView() {mWebView = (WebView) findViewById(R.id.webview);}@SuppressLint("SetJavaScriptEnabled")public void initData() {String url = getIntent().getStringExtra(KEY_URL);if (StringUtil.isEmpty(url)) {finish();return;}String title = getIntent().getStringExtra(KEY_TITLE);if (null == title) {hideTitle(true);} else {setTitleText(title);}com.tencent.smtt.sdk.WebSettings settings = mWebView.getSettings();settings.setJavaScriptEnabled(true);settings.setCacheMode(WebSettings.LOAD_NO_CACHE);mWebView.setWebChromeClient(new WebChromeClient() {public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {AlertDialog.Builder builder = new AlertDialog.Builder(CommWebActivity.this);builder.setCancelable(false).setTitle("温馨提示").setMessage(message).setNeutralButton("确定", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface arg0, int arg1) {finish();}}).show();result.cancel();return true;}});mWebView.setWebViewClient(new WebViewClient() {@Overridepublic boolean shouldOverrideUrlLoading(WebView view, String url) {if (url.startsWith("tel:")) {Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));startActivity(intent);return true;}return super.shouldOverrideUrlLoading(view, url);}@Overridepublic void onPageStarted(WebView view, String url, Bitmap favicon) {// showLoadDialog();showProgressDialog();super.onPageStarted(view, url, favicon);}@Overridepublic void onPageFinished(WebView view, String url) {super.onPageFinished(view, url);dismissProgressDialog();if (TextUtils.isEmpty(getTitleText())) {setTitleText(mWebView.getTitle());}}});mWebView.loadUrl(url);}@Overridepublic boolean onKeyDown(int keyCode, KeyEvent event) {if (keyCode == KeyEvent.KEYCODE_BACK) {if (mWebView.canGoBack()) {mWebView.goBack();return true;}}return super.onKeyDown(keyCode, event);}@Overrideprotected void onDestroy() {super.onDestroy();if (mWebView != null) {mWebView.destroy();}}}
 

最后在Application要加上:

super.onCreate();//搜集本地tbs内核信息并上报服务器,服务器返回结果决定使用哪个内核。QbSdk.PreInitCallback cb = new QbSdk.PreInitCallback() {@Overridepublic void onViewInitFinished(boolean arg0) {// TODO Auto-generated method stub//x5內核初始化完成的回调,为true表示x5内核加载成功,否则表示x5内核加载失败,会自动切换到系统内核。Log.d("app", " onViewInitFinished is " + arg0);}@Overridepublic void onCoreInitFinished() {// TODO Auto-generated method stub}};//x5内核初始化接口QbSdk.initX5Environment(getApplicationContext(),  cb);


阅读全文
0 0
原创粉丝点击