FATAL EXCEPTION : main
<p>Hi everyone this is my first Android app. I new to Java and Eclipse so excuse any "noobity".
I created this project and the tried to run it on my device (nexus s). This is what i get in the LogCat.</p>

<pre><code>12-17 21:03:11.550: E/AndroidRuntime(20786): FATAL EXCEPTION: main  
12-17 21:03:11.550: E/AndroidRuntime(20786): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.gsmdata/com.example.gsmdata.GsmDataActivity}: java.lang.NullPointerException  
12-17 21:03:11.550: E/AndroidRuntime(20786):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)  
12-17 21:03:11.550: E/AndroidRuntime(20786):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)  
12-17 21:03:11.550: E/AndroidRuntime(20786):    at android.app.ActivityThread.access$1500  (ActivityThread.java:117)  
12-17 21:03:11.550: E/AndroidRuntime(20786):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)  
12-17 21:03:11.550: E/AndroidRuntime(20786):    at android.os.Handler.dispatchMessage(Handler.java:99)  
12-17 21:03:11.550: E/AndroidRuntime(20786):    at android.os.Looper.loop(Looper.java:130)  
12-17 21:03:11.550: E/AndroidRuntime(20786):    at android.app.ActivityThread.main(ActivityThread.java:3683)  
12-17 21:03:11.550: E/AndroidRuntime(20786):    at java.lang.reflect.Method.invokeNative(Native Method)  
12-17 21:03:11.550: E/AndroidRuntime(20786):    at java.lang.reflect.Method.invoke(Method.java:507)  
12-17 21:03:11.550: E/AndroidRuntime(20786):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)  
12-17 21:03:11.550: E/AndroidRuntime(20786):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)  
12-17 21:03:11.550: E/AndroidRuntime(20786):    at dalvik.system.NativeStart.main(Native Method)  
12-17 21:03:11.550: E/AndroidRuntime(20786): Caused by: java.lang.NullPointerException  
12-17 21:03:11.550: E/AndroidRuntime(20786):    at com.example.gsmdata.GsmDataActivity.onCreate(GsmDataActivity.java:72)  
12-17 21:03:11.550: E/AndroidRuntime(20786):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)  
12-17 21:03:11.550: E/AndroidRuntime(20786):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)  
12-17 21:03:11.550: E/AndroidRuntime(20786):    ... 11 more
</code></pre>

<hr>

<pre><code>public class GsmDataActivity extends Activity {
/** Called when the activity is first created. */ 

int[] SignalStrength = {
        -113,
        -111,
        -109,
        -107,
        -105,
        -103,
        -101,
        -99,
        -97,
        -95,
        -93,
        -91,
        -89,
        -87,
        -85,
        -83,
        -81,
        -79,
        -77,
        -75,
        -73,
        -71,
        -69,
        -67,
        -65,
        -63,
        -61,
        -59,
        -57,
        -55,
        -53,
        -51};

int network_type,signal_strength,cid,Lac,bts;
TextView network, signal, ci, lac;
TelephonyManager phone;
GsmCellLocation cellId;
CdmaCellLocation baseStation;
SignalStrength phone_sig;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);    

    network = (TextView) findViewById(R.id.tvNetwork);
    signal =(TextView) findViewById(R.id.tvSignalValue);
    ci = (TextView) findViewById(R.id.tvCiValue);
    lac = (TextView) findViewById(R.id.tvLacValue);

    network_type=phone.getNetworkType();

    switch (network_type){ 

    case 1: network.setText("GPRS");
    case 3: network.setText("UMTS");
    case 4: network.setText("CDMA");
    case 8: network.setText("HSDPA");
    case 9: network.setText("HSUPA");
    case 10: network.setText("HSPA");
    case 13: network.setText("LTE");
    default: network.setText("UNKNOWN");      

    }

    if (network_type==1){
        signal_strength = phone_sig.getGsmSignalStrength();
        signal.setText(SignalStrength[signal_strength] + "dBm");
        cid= cellId.getCid();
        Lac=cellId.getLac();
    }
    else if(network_type==0){
        signal.setText("Unknown Network type");
    }
    else{
        signal_strength= phone_sig.getCdmaDbm();
        signal.setText(SignalStrength[signal_strength] + "dBm");
        bts= baseStation.getBaseStationId(); 
        Lac=cellId.getLac();
    }


}



}
</code></pre>

<p>This is my java class. I get a FATAL EXCEPTION in main. I dont know why. Can you help me. Thank you in advance. Following is the xml code :</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
&gt;

 &lt;TextView 
android:layout_width= "fill_parent"
android:layout_height="wrap_content"
android:textSize="50dp"
android:paddingBottom="5dp"
android:id="@+id/tvNetwork"
&gt;&lt;/TextView&gt;
&lt;TextView  
android:layout_width="fill_parent" 
android:layout_height="wrap_content"
 android:text="@string/strength"
 android:layout_gravity="center"
    android:paddingBottom="5dp"
 android:id="@+id/tvSignal"
/&gt;
&lt;TextView 
android:layout_width= "fill_parent"
android:layout_height="wrap_content" 
android:textSize="50dp"
android:paddingBottom="5dp"
android:gravity="center"
android:id="@+id/tvSignalValue"
&gt;&lt;/TextView&gt;
&lt;TextView  
android:layout_width="fill_parent" 
android:layout_height="wrap_content"
android:text="@string/cellid"
 android:layout_gravity="center"
 android:paddingBottom="5dp"
 android:id="@+id/tvCi"
/&gt;
 &lt;TextView 
android:layout_width= "fill_parent"
android:layout_height="wrap_content" 
android:textSize="50dp"
android:paddingBottom="5dp"
android:gravity="center"
android:id="@+id/tvCiValue"
&gt;&lt;/TextView&gt;   
&lt;TextView  
android:layout_width="fill_parent" 
android:layout_height="wrap_content"
 android:text="@string/lac"
 android:layout_gravity="center"
 android:id="@+id/tvLac"
/&gt;
&lt;TextView 
android:layout_width= "fill_parent"
android:layout_height="wrap_content" 
android:textSize="50dp"
android:paddingBottom="5dp"
android:gravity="center"
android:id="@+id/tvLacValue"
&gt;&lt;/TextView&gt;    
&lt;/LinearLayout&gt;
</code></pre>
