how to get static string initialize a textview when activity starts up?
<p>i'm trying to initialize my textview using a static string whenever i launch this activity but emulator always force closes the activity.. can anyone help me out?</p>

<p>Here's the code:</p>

<pre><code>// ServiceAct.java
public class ServiceAct extends Activity
{
    static String[] phoneno = {"No Number", "No Number", "No Number"};

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        // to set the contacts value in status module
        TextView v1 = (TextView) findViewById(R.id.stat_con1);
        v1.setText(phoneno[0]);

        //remaining code of the activity
        ....
    }
}
</code></pre>

<p>here's the logcat</p>

<pre><code>FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.service/com.example.service.ServiceAct}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.example.service.ServiceAct.onCreate(ServiceAct.java:31)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
</code></pre>

<p>here's the layout 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:weightSum="1"  android:layout_height="fill_parent"  android:orientation="horizontal"  android:layout_width="fill_parent"  android:background="@color/background" &gt;

    &lt;RelativeLayout android:layout_height="match_parent"  android:layout_width="match_parent"  android:layout_gravity="center"  android:id="@+id/relativeLayout2"&gt;

        &lt;TextView android:text="No Number"  android:id="@+id/stat_con1"  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:textAppearance="?android:attr/textAppearanceLarge" /&gt;

    &lt;/RelativeLayout&gt;

&lt;/LinearLayout&gt;
</code></pre>
