2016-11-30 63 views
0

我尝试添加http://208.77.22.13/proprek_android/property-listing-trends.php?PropertyID=63&placeId=1&property_type=1&BuildingName=Arabian%20Ranches%20&BedRooms=4的Android Webview是慢

在网页流量,但它的加载速度非常slow.I试图桌面浏览器它的加载速度非常快。

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); 
    } 

我将此代码添加到Android,但stil缓慢为什么?

+0

我添加了一个完整的代码是更新鲜和工作。你可以看看它。 –

回答

0

1.build.gradle(项目)

// Top-level build file where you can add configuration options common to all sub-projects/modules. 

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.2.2' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
     maven { 
      url 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2'} 
    } // this is the single line you are adding to project level gradle file.else is generated. 
} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 
  • 的build.gradle(APP)

    apply plugin: 'com.android.application' 
    
    android { 
        compileSdkVersion 25 //put your desired version 
        buildToolsVersion "25.0.0" // put your desired version 
        defaultConfig { 
         applicationId "com.example.arsensench.xwalk" //put your package name 
         minSdkVersion 16 // min sdk should be 16 
         targetSdkVersion 25 // target sdk can be your desierd 
         versionCode 1 
         versionName "1.0" 
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
        } 
        buildTypes { 
         release { 
          minifyEnabled false 
          proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
         } 
        } 
    } 
    
    dependencies { 
        compile fileTree(dir: 'libs', include: ['*.jar']) 
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
         exclude group: 'com.android.support', module: 'support-annotations' 
        }) 
        compile 'com.android.support:appcompat-v7:25.0.1' 
        testCompile 'junit:junit:4.12' 
        //until here everything is generated 
        //the line below is using the latest XWALK. 
    compile 'org.xwalk:xwalk_core_library:22.52.561.4' 
    

    }

  • 3. AndroidManifest.xml中

    <?xml version="1.0" encoding="utf-8"?> 
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
        package="com.example.arsensench.xwalk"><!-- your package name--> 
        <uses-permission android:name="android.permission.INTERNET"></uses-permission> 
        <application 
         android:allowBackup="true" 
         android:icon="@mipmap/ic_launcher" 
         android:label="@string/app_name" 
         android:supportsRtl="true" 
         android:theme="@style/AppTheme"> 
         <activity android:name=".MainActivity"> 
          <intent-filter> 
           <action android:name="android.intent.action.MAIN" /> 
    
           <category android:name="android.intent.category.LAUNCHER" /> 
          </intent-filter> 
         </activity> 
        </application> 
    
    </manifest> 
    

    4.MainActivity.xml

    <?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
        xmlns:tools="http://schemas.android.com/tools" 
        android:id="@+id/activity_main" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        tools:context="com.example.arsensench.xwalk.MainActivity"> <!--your class path--> 
    
        <org.xwalk.core.XWalkView 
         android:id="@+id/xwalkWebView" 
         android:orientation="vertical" 
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent" 
         android:background="#000000" 
         /> 
    </RelativeLayout> 
    

    5.MainActivity.java()

    import android.support.v7.app.AppCompatActivity; 
    import android.os.Bundle; 
    import org.xwalk.core.XWalkView; 
    
    public class MainActivity extends AppCompatActivity { 
    
        @Override 
        protected void onCreate(Bundle savedInstanceState) { 
         super.onCreate(savedInstanceState); 
         setContentView(R.layout.activity_main); 
    
         XWalkView xWalkWebView=(XWalkView)findViewById(R.id.xwalkWebView); 
         xWalkWebView.load("http://208.77.22.13/proprek_android/property-listing-trends.php?PropertyID=63&placeId=1&property_type=1&BuildingName=Arabian%20Ranches%20&BedRooms=4", null); 
        } 
    } 
    
    +0

    这应该是一个评论!平静下来@Piyush – Piyush

    +1

    。代码已经到达。 –

    +0

    即使在PC Google chrome上,您的网站也正在加载和滚动。它与你的网站有关。例如http://www.theverge.com/正与我为您提供的代码合作。 –

    1

    我检查你在我的浏览器给URL,它需要近30秒加载,所以没有什么不对您的代码

    +0

    为真。这个页面在运行时加载了几十秒......也许你的桌面通过以太网连接或缓存了这个站点? – snachmsm