Jithin P Jithin P - 2 days ago 6
Android Question

Android Webview is slow

I tried to add http://208.77.22.13/proprek_android/property-listing-trends.php?PropertyID=63&placeId=1&property_type=1&BuildingName=Arabian%20Ranches%20&BedRooms=4

in webview but its loading speed is very slow.I tried in desktop browser its loading is very fast.

wv1 = (WebView) findViewById(R.id.webviewdetail);
WebSettings webSettings = wv1.getSettings();
webSettings.setLoadsImagesAutomatically(true);
webSettings.setJavaScriptEnabled(true);
webSettings.setLoadWithOverviewMode(true);
webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);


if (Build.VERSION.SDK_INT >= 19) {
// chromium, enable hardware acceleration
wv1.setLayerType(View.LAYER_TYPE_HARDWARE, null);
} else {
// older android version, disable hardware acceleration
wv1.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}


i added this code to android but stil slow why?

Answer

Check out CrossWalkView. But I agree with Akshay Panchal, your site is very heavy.

1.Open AndroidStudio to project view in app folder edit build.gradle:

repositories {
maven {
url 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2'}}


dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'org.xwalk:xwalk_core_library:10.39.235.15'}

2.add this view in layout xml.

<org.xwalk.core.XWalkView
android:id="@+id/xwalkWebView"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000"
/>

3.in onCreate:

XWalkView xWalkWebView=(XWalkView)findViewById(R.id.xwalkWebView);
xWalkWebView.clearCache(true);
xWalkWebView.load("http://...", null);
// turn on debugging
XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, true);

Do not forget to sync the project after gradle changes and also import needed packages in your activity.

Comments