Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/188.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java WebView膨胀异常_Java_Android_Android Webview - Fatal编程技术网

Java WebView膨胀异常

Java WebView膨胀异常,java,android,android-webview,Java,Android,Android Webview,在我的活动中,我添加了Webview(没有异常): 问题是我的应用程序在一些android设备上崩溃(在Crashlytics中看到过)。。。我在emulator上重现了这种情况,并获得了此日志(第一部分): 我找到了很好的解决方案-创建类并使用它来代替基本Webview: public class LollipopFixedWebView extends WebView { public LollipopFixedWebView(Context context) {

在我的活动中,我添加了Webview(没有异常):

问题是我的应用程序在一些android设备上崩溃(在Crashlytics中看到过)。。。我在emulator上重现了这种情况,并获得了此日志(第一部分):

我找到了很好的解决方案-创建类并使用它来代替基本Webview:

public class LollipopFixedWebView extends WebView {

    public LollipopFixedWebView(Context context) {
        super(getFixedContext(context));
    }

    public LollipopFixedWebView(Context context, AttributeSet attrs) {
        super(getFixedContext(context), attrs);
    }

    public LollipopFixedWebView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(getFixedContext(context), attrs, defStyleAttr);
    }

    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    public LollipopFixedWebView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(getFixedContext(context), attrs, defStyleAttr, defStyleRes);
    }

    public LollipopFixedWebView(Context context, AttributeSet attrs, int defStyleAttr, boolean privateBrowsing) {
        super(getFixedContext(context), attrs, defStyleAttr, privateBrowsing);
    }

    public static Context getFixedContext(Context context) {
        return context.createConfigurationContext(new Configuration());
    }
}
好的,没有更多的崩溃,很好,但是:我加载了包含html中的Select标记的页面,如果点击它就不起作用了!基本上,android必须用Select的变量打开系统对话框,但它不

有什么想法吗?

只要做-:

改变

<WebView
        tools:context=".Activities.WebViewActivity"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/webView"/>
简单地做-:

改变

<WebView
        tools:context=".Activities.WebViewActivity"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/webView"/>
看看我的答案

简而言之:仅在默认的
上下文
导致
充气异常的操作系统版本上使用固定的
上下文

private static Context getFixedContext(Context context) {
    if (Build.VERSION.SDK_INT >= 21 && Build.VERSION.SDK_INT < 23) // Android Lollipop 5.0 & 5.1
        return context.createConfigurationContext(new Configuration());
    return context;
}
私有静态上下文getFixedContext(上下文上下文){
if(Build.VERSION.SDK_INT>=21&&Build.VERSION.SDK_INT<23)//Android棒棒糖5.0和5.1
返回context.createConfigurationContext(新配置());
返回上下文;
}
在中查看我的答案

简而言之:仅在默认的
上下文
导致
充气异常的操作系统版本上使用固定的
上下文

private static Context getFixedContext(Context context) {
    if (Build.VERSION.SDK_INT >= 21 && Build.VERSION.SDK_INT < 23) // Android Lollipop 5.0 & 5.1
        return context.createConfigurationContext(new Configuration());
    return context;
}
私有静态上下文getFixedContext(上下文上下文){
if(Build.VERSION.SDK_INT>=21&&Build.VERSION.SDK_INT<23)//Android棒棒糖5.0和5.1
返回context.createConfigurationContext(新配置());
返回上下文;
}

你想使用简单网络视图还是棒棒糖FixedWebView???@ShivamOberoi我想使用一些能很好工作的东西。好的,让我们使用棒棒糖FixedWebView你想使用简单的web视图还是棒棒糖FixedWebView???@ShivamOberoi我想使用一些能很好工作的东西。好的,让我们使用棒棒糖FixedWebViewNo,这个解决方案阻止html中的Select标记!我的意思是,如果我使用这个代码应用程序将不会崩溃,但在我的棒棒糖FixedWebView中,我不能在html中使用。这很重要。也许我可以在Webview上处理单击并绘制自定义对话框,而不是本机?也许我需要写一些代码到LollipofFixedWebView来解决这个问题?不,这个解决方案阻止html中的Select标记!我的意思是,如果我使用这个代码应用程序将不会崩溃,但在我的棒棒糖FixedWebView中,我不能在html中使用。这很重要。也许我可以在Webview上处理单击并绘制自定义对话框,而不是本机?也许我需要写一些代码到LollipofFixedWebView来解决这个问题?很好,但我想html的问题没有解决@snachmsm不,它没有。。。所以,我有一个新问题。如果我在html中按,应用程序将因以下日志而崩溃:无法添加窗口--令牌null不适用于应用程序。我假设系统正在尝试打开SelectPopupDialog,但由于“空令牌”,无法打开。但我用Activitiy的上下文创建了棒棒糖FixedWebView@你运气好吗?我也面临这个问题,再次使用这个解决方案你好,是的,解决方案已经建立,但我不知道我是如何做到的。。。我记得,在某些情况下,当一些设备/系统没有稳定的WebView组件或Google Play服务时,这是Android的失败,但我想html的问题并没有解决@snachmsm不,它没有。。。所以,我有一个新问题。如果我在html中按,应用程序将因以下日志而崩溃:无法添加窗口--令牌null不适用于应用程序。我假设系统正在尝试打开SelectPopupDialog,但由于“空令牌”,无法打开。但我用Activitiy的上下文创建了棒棒糖FixedWebView@你运气好吗?我也面临这个问题,再次使用这个解决方案你好,是的,解决方案已经建立,但我不知道我是如何做到的。。。我记得,在某些情况下,当一些设备/系统没有稳定的WebView组件或Google Play服务时,这是Android的失败
<yourpackgename.LollipopFixedWebView
        tools:context=".Activities.WebViewActivity"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/webView"/>
LollipopFixedWebView webview=findViewById(R.id.webview);
private static Context getFixedContext(Context context) {
    if (Build.VERSION.SDK_INT >= 21 && Build.VERSION.SDK_INT < 23) // Android Lollipop 5.0 & 5.1
        return context.createConfigurationContext(new Configuration());
    return context;
}