Hello.
There was a strange problem. I'm trying to load html, but no WebView (link null ).
Calling an Activity from WebView :

 Intent intent = new Intent(); intent.setClass(this, aboutProg.class); startActivity(intent); 

onCreate Activity onCreate Method

 private String uriFile = "file:///android_asset/"; private WebView wv; public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.about_programm); wv = (WebView)this.findViewById(R.id.textAboutUsWeb);//в том месте не находит wv.loadUrl(uriFile+"textAboutUs.html");//а тут вылетает, потому что wv - null } 

And about_programm.xml file

 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#fff"> <WebView android:id="@+id/textAboutUsWeb" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </RelativeLayout> 

Shl. This problem occurs on tablets with android 3.2 and 2.3 . On phones with android 2.3 works.

  • And you didn’t try to download the dock right away (wv.loadUrl(uriFile+"textAboutUs.html") , but for example the text. There may be problems with paths or rights. - evgeniy
  • The fact is that webview refers to null - andreich
  • add button try to find it =) - Gorets

2 answers 2

  1. Try compiling for API 12-13 with minSDK <= 10

  2. The tablet and phone may differ in hardware requirements - theoretically this could be the reason. Paste such a "universal" script into the manifest

-

 <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" /> <compatible-screens> <screen android:screenSize="small" android:screenDensity="ldpi"/> <screen android:screenSize="small" android:screenDensity="mdpi"/> <screen android:screenSize="small" android:screenDensity="hdpi"/> <screen android:screenSize="small" android:screenDensity="xhdpi"/> <screen android:screenSize="normal" android:screenDensity="ldpi"/> <screen android:screenSize="normal" android:screenDensity="mdpi"/> <screen android:screenSize="normal" android:screenDensity="hdpi"/> <screen android:screenSize="normal" android:screenDensity="xhdpi"/> <screen android:screenSize="large" android:screenDensity="ldpi"/> <screen android:screenSize="large" android:screenDensity="mdpi"/> <screen android:screenSize="large" android:screenDensity="hdpi"/> <screen android:screenSize="large" android:screenDensity="xhdpi"/> <screen android:screenSize="xlarge" android:screenDensity="ldpi"/> <screen android:screenSize="xlarge" android:screenDensity="mdpi"/> <screen android:screenSize="xlarge" android:screenDensity="hdpi"/> <screen android:screenSize="xlarge" android:screenDensity="xhdpi"/> </compatible-screens> <uses-feature android:name="android.hardware.telephony" android:required="false"/> <uses-feature android:name="android.hardware.camera" android:required="false"/> <uses-feature android:name="android.hardware.touchscreen" android:required="false"/> <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="15"/> 

I have a similar problem solved in this way.

    In general, the other day I had problems with displaying the interface on various screens, and for this I created another layout-xlarge folder. And when I added webview to the layout folder, I forgot to add it to layout-xlarg. Accordingly, it crashed on the tablets, and everything worked on the phones.