所以我有一个应用程序,它将文件存储在我创建的目录中,当用户到达某个地理位置的一定距离内时。一切正常,除了某些通常使用 sd 卡的设备将其删除,然后当用户登录时应用程序崩溃。我尝试了 droid x,我能够复制崩溃。当我有 sd 卡时它工作正常,但是当 sd 卡被移除时,我得到一个空指针异常并强制关闭。
以下是市场上的日志转储:
java.lang.RuntimeException: Unable to resume activity {graffit.cores/graffit.cores.GraffView}: java.lang.NullPointerException
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2208)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2228)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1721)
at android.app.ActivityThread.access$1500(ActivityThread.java:124)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:968)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3806)
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 graffit.cores.GraffView.onResume(GraffView.java:1201)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1150)
at android.app.Activity.performResume(Activity.java:3882)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2191)
... 12 more
java.lang.NullPointerException
at graffit.cores.GraffView.onResume(GraffView.java:1201)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1150)
at android.app.Activity.performResume(Activity.java:3882)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2191)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2228)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1721)
at android.app.ActivityThread.access$1500(ActivityThread.java:124)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:968)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3806)
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)
由于日志转储说明了有关检测失败的信息,我猜我应该抓住它或寻找是否有可用的 SD 卡。
我确定我可以找到如何查找 sd 卡,但我怎样才能赶上这次崩溃并使用内部存储来代替丢失的 sd 卡。
任何帮助将非常感激。