Почему мое приложение принудительно закрывается, когда я нажимаю кнопку, чтобы запустить первое действие
Это начальное действие:
public class ForeverAlone extends Activity implements OnClickListener{
/** Called when the activity is first created. */
Button start;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
start = (Button) findViewById(R.id.bStart);
start.setOnClickListener(this);
}
@Override
public void onClick(View v) {
Intent myIntent = new Intent(ForeverAlone.this, First.class);
ForeverAlone.this.startActivity(myIntent);
}
}
Это действие, которое СЛЕДУЕТ прибытьпосле того, как я нажму кнопку:
public class First extends Activity implements OnClickListener {
Button firstNext;
EditText firstFacebook, firstReallife;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.first);
firstNext = (Button) findViewById(R.id.bFirstNext);
firstFacebook = (EditText) findViewById(R.id.etFirst1);
firstReallife = (EditText) findViewById(R.id.etFirst2);
firstNext.setOnClickListener(this);
String firstFB = firstFacebook.getText().toString();
String firstRL = firstReallife.getText().toString();
DataHelper.insert(firstFB, firstRL);
}
@Override
public void onClick(View v) {
Intent myIntent = new Intent(First.this, Second.class);
First.this.startActivity(myIntent);
}
}
Любая помощь будет приветствоваться!
[Редактировать]
Вот LogCat:
01-08 19:19:55.656: D/dalvikvm(363): GC_EXTERNAL_ALLOC freed 50K, 53% free 2553K/5379K, external 1625K/2137K, paused 76ms
01-08 19:19:57.966: D/AndroidRuntime(363): Shutting down VM
01-08 19:19:57.966: W/dalvikvm(363): threadid=1: thread exiting with uncaught exception (group=0x40015560)
01-08 19:19:57.986: E/AndroidRuntime(363): FATAL EXCEPTION: main
01-08 19:19:57.986: E/AndroidRuntime(363): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kenning.foreveralone/com.kenning.foreveralone.First}: java.lang.NumberFormatException: unable to parse '' as integer
01-08 19:19:57.986: E/AndroidRuntime(363): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
01-08 19:19:57.986: E/AndroidRuntime(363): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
01-08 19:19:57.986: E/AndroidRuntime(363): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-08 19:19:57.986: E/AndroidRuntime(363): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
01-08 19:19:57.986: E/AndroidRuntime(363): at android.os.Handler.dispatchMessage(Handler.java:99)
01-08 19:19:57.986: E/AndroidRuntime(363): at android.os.Looper.loop(Looper.java:123)
01-08 19:19:57.986: E/AndroidRuntime(363): at android.app.ActivityThread.main(ActivityThread.java:3683)
01-08 19:19:57.986: E/AndroidRuntime(363): at java.lang.reflect.Method.invokeNative(Native Method)
01-08 19:19:57.986: E/AndroidRuntime(363): at java.lang.reflect.Method.invoke(Method.java:507)
01-08 19:19:57.986: E/AndroidRuntime(363): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-08 19:19:57.986: E/AndroidRuntime(363): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-08 19:19:57.986: E/AndroidRuntime(363): at dalvik.system.NativeStart.main(Native Method)
01-08 19:19:57.986: E/AndroidRuntime(363): Caused by: java.lang.NumberFormatException: unable to parse '' as integer
01-08 19:19:57.986: E/AndroidRuntime(363): at java.lang.Integer.parseInt(Integer.java:362)
01-08 19:19:57.986: E/AndroidRuntime(363): at java.lang.Integer.parseInt(Integer.java:332)
01-08 19:19:57.986: E/AndroidRuntime(363): at java.lang.Integer.<init>(Integer.java:105)
01-08 19:19:57.986: E/AndroidRuntime(363): at com.kenning.foreveralone.DataHelper.insert(DataHelper.java:9)
01-08 19:19:57.986: E/AndroidRuntime(363): at com.kenning.foreveralone.First.onCreate(First.java:27)
01-08 19:19:57.986: E/AndroidRuntime(363): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-08 19:19:57.986: E/AndroidRuntime(363): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
01-08 19:19:57.986: E/AndroidRuntime(363): ... 11 more
[Редактировать]
Я нашел причину проблемы "принудительное закрытие".
Вот эти строки кода:
String firstFB = firstFacebook.getText().toString();
String firstRL = firstReallife.getText().toString();
DataHelper.insert(firstFB, firstRL);
Как мне остановитьспособ столкнуться с ними и как-то пропустить их?