Integer.parseInt force closes my android app to close
<p>Here is my original code:</p>

<pre><code>final EditText t1 = (EditText)findViewById(R.id.editText1);
int a = Integer.parseInt(t1.getText().toString());
</code></pre>

<p>Now with this code i get force close when i run on emulator.</p>

<p>So i serperated it to this</p>

<pre><code>String s = t1.getText().toString();
</code></pre>

<p>Everything goes correctly, but when i change it to:</p>

<pre><code>String s = t1.getText().toString();
int a = Integer.parseInt(s);
</code></pre>

<p>Then it force closes again.</p>

<p>edit:</p>

<p>I had the code in a button click listener like this:</p>

<pre><code>button.setOnClickListener(new View.OnClickListener() 
    {
        public void onClick(View v) 
        {
            int a = 0;
            int b = 0;
            try
            {
                a = Integer.parseInt(t1.getText().toString());
                b = Integer.parseInt(t2.getText().toString());
            }
            catch(NumberFormatException e)
            {
                alert.show();
            }


        }
    });
</code></pre>

<p>But when i took it out, it does catch the exception correctly. Give me a minute and ill get the logcat.</p>

<pre><code>    07-26 07:54:14.360: ERROR/AndroidRuntime(711): FATAL EXCEPTION: main
07-26 07:54:14.360: ERROR/AndroidRuntime(711): android.content.res.Resources$NotFoundException: String resource ID #0x7
07-26 07:54:14.360: ERROR/AndroidRuntime(711):     at android.content.res.Resources.getText(Resources.java:201)
07-26 07:54:14.360: ERROR/AndroidRuntime(711):     at android.widget.TextView.setText(TextView.java:2857)
07-26 07:54:14.360: ERROR/AndroidRuntime(711):     at com.testing.test2.Test2Activity$1.onClick(Test2Activity.java:47)
07-26 07:54:14.360: ERROR/AndroidRuntime(711):     at android.view.View.performClick(View.java:2485)
07-26 07:54:14.360: ERROR/AndroidRuntime(711):     at android.view.View$PerformClick.run(View.java:9080)
07-26 07:54:14.360: ERROR/AndroidRuntime(711):     at android.os.Handler.handleCallback(Handler.java:587)
07-26 07:54:14.360: ERROR/AndroidRuntime(711):     at android.os.Handler.dispatchMessage(Handler.java:92)
07-26 07:54:14.360: ERROR/AndroidRuntime(711):     at android.os.Looper.loop(Looper.java:123)
07-26 07:54:14.360: ERROR/AndroidRuntime(711):     at android.app.ActivityThread.main(ActivityThread.java:3683)
07-26 07:54:14.360: ERROR/AndroidRuntime(711):     at java.lang.reflect.Method.invokeNative(Native Method)
07-26 07:54:14.360: ERROR/AndroidRuntime(711):     at java.lang.reflect.Method.invoke(Method.java:507)
07-26 07:54:14.360: ERROR/AndroidRuntime(711):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-26 07:54:14.360: ERROR/AndroidRuntime(711):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-26 07:54:14.360: ERROR/AndroidRuntime(711):     at dalvik.system.NativeStart.main(Native Method)
07-26 07:54:14.430: WARN/ActivityManager(68):   Force finishing activity com.testing.test2/.Test2Activity
07-26 07:54:14.940: WARN/ActivityManager(68): Activity pause timeout for HistoryRecord{405e8368 com.testing.test2/.Test2Activity}
07-26 07:54:16.349: INFO/Process(711): Sending signal. PID: 711 SIG: 9
07-26 07:54:16.389: INFO/ActivityManager(68): Process com.testing.test2 (pid 711) has died.
07-26 07:54:16.399: INFO/WindowManager(68): WIN DEATH: Window{407013e0 com.testing.test2/com.testing.test2.Test2Activity paused=false}
07-26 07:54:16.689: WARN/InputManagerService(68): Got RemoteException sending setActive(false) notification to pid 711 uid 10035
07-26 07:54:21.599: DEBUG/dalvikvm(258): GC_EXPLICIT freed 6K, 54% free 2597K/5639K, external 410K/517K, paused 76ms
07-26 07:54:26.650: DEBUG/dalvikvm(303): GC_EXPLICIT freed 6K, 54% free 2544K/5511K, external 410K/517K, paused 100ms
07-26 07:54:31.640: DEBUG/dalvikvm(315): GC_EXPLICIT freed 1K, 54% free 2538K/5511K, external 410K/517K, paused 72ms
</code></pre>
