打开其他应用后Android应用崩溃了

时间:2015-10-26 20:41:09

标签: android android-activity crash

我的应用有问题。该应用程序完美。如果我按下后退按钮,应用程序显然会关闭而没有任何问题。如果我按下主页按钮,应用程序就在后台。如果我立即打开应用程序,这是有效的,但如果我打开其他应用程序,然后我打开我的应用程序经常崩溃。

我该如何解决?我必须实现onPause方法吗?但是如何?

26 21:46:27.341  29621-29621/parlamento_italiano.android E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: parlamento_italiano.android, PID: 29621
java.lang.RuntimeException: Unable to start activity ComponentInfo{parlamento_italiano.android/com.prova.prova3.Quarta}: java.lang.NumberFormatException: Invalid int: ""
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3119)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3218)
        at android.app.ActivityThread.access$1000(ActivityThread.java:198)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1676)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:145)
        at android.app.ActivityThread.main(ActivityThread.java:6837)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
 Caused by: java.lang.NumberFormatException: Invalid int: ""
        at java.lang.Integer.invalidInt(Integer.java:138)
        at java.lang.Integer.parseInt(Integer.java:358)
        at java.lang.Integer.parseInt(Integer.java:334)
        at com.prova.prova3.R2.onCreateView(R2.java:77)
        at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1026)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1207)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1189)
        at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2001)
        at android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:165)
        at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:507)
        at com.prova.prova3.Quarta.onStart(Quarta.java:291)
        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1250)
        at android.app.Activity.performStart(Activity.java:6538)

导致崩溃

        int x = Integer.parseInt(numVoti.replaceAll("[\\D]", ""));

1 个答案:

答案 0 :(得分:0)

首先,当您按下主页按钮时,您的应用程序不会进入后台。它只会添加到Back Stack中。其次,尝试向我们解释您的应用使用的资源,以及它们与其他应用的互动方式。