HiteshGs
HiteshGs

Reputation: 587

webview freeze in android 4.4.2

i have an application in that i am loading webview in activity with url also there is drawer and this is freeze in android 4.4.2 , thats working fine in android 5.0 and 6.0 onward

as per android monitor log in freeze case is below , thats log is repeat on every swype or touch

and i set webview property like

webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setDomStorageEnabled(true);
    webView.getSettings().setPluginState(PluginState.ON);
    webView.getSettings().setRenderPriority(RenderPriority.HIGH);
    webView.getSettings().setGeolocationEnabled(true);
    webView.getSettings().setPluginState(WebSettings.PluginState.ON);
    webView.getSettings().setAllowFileAccess(true);

and i set webclient

webView.setWebChromeClient(new WebChromeClient() {            

@Override public boolean onShowFileChooser(WebView webView, ValueCallback filePathCallback, FileChooserParams fileChooserParams) { return true; } @Override public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) { callback.invoke(origin, true, false); } // openFileChooser for Android 3.0+ public void openFileChooser(ValueCallback uploadMsg, String acceptType) { } // openFileChooser for Android < 3.0 public void openFileChooser(ValueCallback uploadMsg) { } //openFileChooser for other Android versions public void openFileChooser(ValueCallback uploadMsg, String acceptType, String capture) { openFileChooser(uploadMsg, acceptType); } public boolean onConsoleMessage(ConsoleMessage cm) { onConsoleMessage(cm.message(), cm.lineNumber(), cm.sourceId()); return true; } public void onConsoleMessage(String message, int lineNumber, String sourceID) { } }); // End setWebChromeClient

    webView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return true;
        }
        @Override

        public void onPageFinished(WebView view, final String url) {

            super.onPageFinished(view, url);
            CookieSyncManager.getInstance().sync();
            Log.i("finished", url);
        }
    });

and here is my xml

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/layMain"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF"
    tools:context=".LandingActivity">

    <WebView
        android:id="@+id/web_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/include"
        android:scrollbarStyle="insideOverlay"
        android:scrollbars="none"
        android:visibility="gone" />
    <ImageView
        android:id="@+id/splash"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="centerCrop"
        android:src="@drawable/splash"
        android:visibility="gone" />
    <include
        android:id="@+id/include"
        layout="@layout/bottom_option"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" />
    <FrameLayout
        android:id="@+id/framLay"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone">
    </FrameLayout>
</RelativeLayout>
<LinearLayout
    android:layout_width="300dp"
    android:layout_height="fill_parent"
    android:layout_gravity="end"
    android:background="@color/white"
    android:orientation="vertical">
    <ListView
        android:id="@+id/navdrawer"
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_gravity="end"
        android:background="@android:color/white"
        android:choiceMode="singleChoice"
        android:drawSelectorOnTop="false"></ListView>
    <View
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:layout_marginBottom="2dp"
        android:layout_marginTop="2dp"
        android:background="#454545" />
    <ListView
        android:id="@+id/navdrawer2"
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_gravity="end"
        android:layout_weight="1"
        android:background="@android:color/white"
        android:choiceMode="singleChoice"
        android:drawSelectorOnTop="false"></ListView>
    <TextView
        android:id="@+id/tvVersion"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="1dp"
        android:gravity="center" />
    <include layout="@layout/listview_bottom" />
</LinearLayout>

Upvotes: 2

Views: 783

Answers (1)

Ucdemir
Ucdemir

Reputation: 3098

Gradle with 3.0.0 and above and compileSdkVersion 26 above cause this problem...

My solution is not exact solution but it solve the problem... switch app gradle to

classpath 'com.android.tools.build:gradle:2.3.0'

switch module gradle to

compileSdkVersion 25
buildToolsVersion '25.0.2'

change all other api to max 25 will solve frezee problem.. Until Main Solution comes it is worth to change these things!

Seems "Kotlin" is not as expected... Cause More work for CPU

Upvotes: 0

Related Questions