WebView没有在所有版本的模拟器上显示html页面,它只在android 2.2上显示?

时间:2014-01-07 07:05:48

标签: android xml

这是从资产文件夹

加载html文件的活动
public class MapActivity  extends Activity {

@SuppressLint("SetJavaScriptEnabled")   private WebView myWebView;
private String url ="file:///android_asset/Map.html";   
@SuppressLint("SetJavaScriptEnabled")
@SuppressWarnings("deprecation")    @Override
 public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     String url = new String("file:///android_asset/Map.html");
     setContentView(R.layout.leaflet_map);
     this.setTitle("Location Map");
     // Obtain the webView by ID

     if (android.os.Build.VERSION.SDK_INT > 9) {        
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();             StrictMode.setThreadPolicy(policy);         }
     initComponent();
     WebSettings webSettings = myWebView.getSettings();
     webSettings.setJavaScriptEnabled(true);
     // performance hacks!
     webSettings.setRenderPriority(RenderPriority.HIGH);
     webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);

     // multi-touch zoom
     webSettings.setBuiltInZoomControls(true);
    /* webSettings.setDisplayZoomControls(false);*/
     myWebView.getSettings().setLoadsImagesAutomatically(true);
     myWebView.setWebViewClient(new WebViewClient());`enter code here`
     myWebView.loadUrl("file:///android_asset/Map.html");
     myWebView.setWebViewClient(new WebViewClient());

 }      public void initComponent(){
            generateId();   }       public void generateId(){
            myWebView = (WebView) findViewById(R.id.webView);   } }

我的清单文件

 <uses-sdk
     android:minSdkVersion="8"
     android:targetSdkVersion="19"/>
 <supports-screens
     android:smallScreens="true"
     android:normalScreens="true"
     android:largeScreens="true"
     android:xlargeScreens="true"/>

 <uses-permission android:name="android.permission.INTERNET"/>
 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission

机器人:名称= “android.permission.WRITE_EXTERNAL_STORAGE”/&GT;     

 <application
     android:allowBackup="true"
     android:icon="@drawable/location_icon"
     android:label="@string/app_name"
     android:theme="@style/Background" >
     <activity
         android:name="com.locationTracker.periscope.MapActivity"
         android:label="@string/app_name" >
         <intent-filter>
             <action android:name="android.intent.action.MAIN" />
         </intent-filter>
     </activity>
     <activity
         android:name="com.locationTracker.periscope.CreateIssue"
         android:label="@string/app_name" >
         <intent-filter>
             <action android:name="android.intent.action.MAIN" />
         </intent-filter>
     </activity>
     <activity
         android:name="com.locationTracker.periscope.SettingPage"
         android:label="@string/app_name" >
         <intent-filter>
             <action android:name="android.intent.action.MAIN" />
         </intent-filter>
     </activity>
     <activity
         android:name="com.locationTracker.periscope.ProjectList"
         android:label="@string/app_name" >
         <intent-filter>
             <action android:name="android.intent.action.MAIN" />
         </intent-filter>
     </activity>
     <activity
         android:name="com.locationTracker.periscope.AndroidXMLParsingActivity"
         android:label="@string/app_name" >
         <intent-filter>
             <action android:name="android.intent.action.MAIN" />
         </intent-filter>
     </activity>
      <activity
         android:name="com.locationTracker.periscope.SingleMenuItemActivity"
         android:label="@string/app_name" >
         <intent-filter>
             <action android:name="android.intent.action.MAIN" />
         </intent-filter>
     </activity>
     <activity
         android:name="com.locationTracker.periscope.Walk_IssueActivity"
         android:label="@string/app_name" >
         <intent-filter>
             <action android:name="android.intent.action.MAIN" />
         </intent-filter>
     </activity>
     <activity
         android:name="com.locationTracker.periscope.MainActivity"
         android:label="@string/app_name" >
         <intent-filter>
             <action android:name="android.intent.action.MAIN" />
             <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
     </activity>
 </application>

0 个答案:

没有答案