1 java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity。

问题:

  • 因为继承了android.support.v7.app下的类,
    LRIZQ2K@CHQC9BD2ZSPHU2O.png

解决:

  • 可以在给继承的类配置v7的theme,也可以直接不用v7的类 。

2 IllegalStateException: Can not perform this action after onSaveInstanceState

问题:

  • 说明某一Action或者该Action引起了另一件事件在onSaveInstanceState之后执行了,但系统不允许这个Action或者某事件在onSaveInstanceState之后执行。

解决:

  • 如果有FragmentManager的commit ,FragmentManager在commit(并没有立即执行)的时候需要在onSaveInstanceState(activity销毁前执行,保存activity数据)之前执行,换成commitAllowingStateLoss(),此方法允许在onSaveInstanceState之后执行。
  • 如果有广播,可能是该广播在activity结束之后执行了,从而引起其他不能在onSaveInstanceState之后执行的事件。可在activity的Ondestory里结束广播。

3 java.util.IllegalFormatConversionException: d != java.lang.Double

问题 :

数字与文字匹配时出错,比如 xxxxx: %1$2.1f%%


4 java.lang.RuntimeException: Parcelable encountered IOException writing serializable object

问题 :

Intent传输对象时,对象要实现serializable接口

解决 :

对象和对象里的嵌套对象都要实现serializable接口

5 unkonw_url_scheme

问题:webView只能识别http://或https://开头的url

解决:来源

webView.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {

                try{
                    if(url.startsWith("baidumap://")){
                        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                        startActivity(intent);
                        return true;
                    }
                }catch (Exception e){
                    return false;
                }
                webView.loadUrl(url);
                return true;
            }
        });

6.is not a concrete class ,Inspection info: Validates resource references inside Android XML files.

解决:去掉abstract

7. Google商店webview ssl问题

https://support.google.com/faqs/answer/7071387
https://developer.android.com/reference/android/webkit/WebViewClient.html#onReceivedSslError(android.webkit.WebView,%20android.webkit.SslErrorHandler,%20android.net.http.SslError)

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐