贴代码
string.xml<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="hello">Hello World, GetDeviceInfo!</string>
    <string name="app_name">apple</string>
    <string name="newact">apple1</string>
</resources>main.xml<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />
</LinearLayout>
css.xml<?xml version="1.0" encoding="utf-8"?>
<TextView 
    android:text="TextView" 
    android:id="@+id/textView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    xmlns:android="http://schemas.android.com/apk/res/android">
</TextView>GetDeviceInfo.javapackage jp.alldin.sdk.common;import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo.State;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.TextView;public class GetDeviceInfo extends Activity {
TextView text;
public  void getDeviceBaicInfo()//获取手机信息
{
TelephonyManager tm = (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
String str = "";
str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion()+ "\n";
str += "Line1Number = " + tm.getLine1Number() + "\n";
str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";
str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";
str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";
str += "NetworkType = " + tm.getNetworkType() + "\n";
str += "honeType = " + tm.getPhoneType() + "\n";
str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";
str += "SimOperator = " + tm.getSimOperator() + "\n";
str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";
str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";
str += "SimState = " + tm.getSimState() + "\n";
str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";
str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";
text.setText(str);
}
public void getPhoneNumber() {
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String imei = tm.getDeviceId();
String tel = tm.getLine1Number();
text.setText("a" + imei + "\n" + "b" + tel + "\n");
}
public void getDeciceNwStatus()//网络识别
 {
 ConnectivityManager connManager = (ConnectivityManager)this.getSystemService(CONNECTIVITY_SERVICE);
 NetworkInfo networkInfo = connManager.getActiveNetworkInfo();  
 boolean available = networkInfo.isAvailable();
 if(available)
 {
   Log.i("a", "a");
 }
 else
 {
   Log.i("b", "b");
 }
 android.net.NetworkInfo.State state = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState();
 if(State.CONNECTED==state)
 {
 Log.i("c", "WIFI");
 }
 android.net.NetworkInfo.State state1 = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState();
 if(State.CONNECTED==state)
 {
   Log.i("c", "GPRS");
 }
 startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));
       startActivity(new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS));
 
}
}
css.javapackage cs;
import jp.alldin.sdk.common.GetDeviceInfo;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;public class css extends Activity {
TextView textView1;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
textView1 = (TextView)findViewById(R.id.textView1);
setContentView(R.layout.css);
a();

}
public static void a()
{
GetDeviceInfo getDeviceInfo= new GetDeviceInfo();
getDeviceInfo.getDeviceBaicInfo();
getDeviceInfo.getPhoneNumber();
getDeviceInfo.getDeciceNwStatus();

}

}AndroidManifest.xml<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="jp.alldin.sdk.common"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.CALL_PHONE"/>
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".css"
           android:label="@string/app_name"> 
           <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".GetDeviceInfo"
                  android:label="@string/app_name">
        </activity>
    
    </application>
</manifest>

解决方案 »

  1.   

    super.onCreate(savedInstanceState);
            textView1 = (TextView)findViewById(R.id.textView1);
            setContentView(R.layout.css);
            a();
    super.onCreate(savedInstanceState);
                   setContentView(R.layout.css);
     textView1 = (TextView)findViewById(R.id.textView1);

            a();
      

  2.   

    css 不是布局文件吧,R.xml.css
      

  3.   

    你还没有设置布局呢,就去findView了,就找不到textView1了。