Kaljurand / Diktofon

An Android app, a dictaphone with Estonian speech-to-text
Apache License 2.0
15 stars 3 forks source link

app sometimes crashes when recording finishes #28

Open dpocock opened 9 years ago

dpocock commented 9 years ago

I've noticed that the app sometimes crashes (force close by Android) when a recording finishes. The recording file is complete and valid but the crash gives a bad impression of the app.

Here is the stack from logcat:

E/AndroidRuntime(11593): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=file:///sdcard/.../whatever.wav }} to activity {kaljurand_at_gmail_dot_com.diktofon/kaljurand_at_gmail_dot_com.diktofon.activity.RecordingListActivity}: java.lang.NullPointerException
E/AndroidRuntime(11593):        at android.app.ActivityThread.deliverResults(ActivityThread.java:3389)
E/AndroidRuntime(11593):        at android.app.ActivityThread.handleSendResult(ActivityThread.java:3432)
E/AndroidRuntime(11593):        at android.app.ActivityThread.access$1300(ActivityThread.java:144)
E/AndroidRuntime(11593):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1253)
E/AndroidRuntime(11593):        at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(11593):        at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime(11593):        at android.app.ActivityThread.main(ActivityThread.java:5146)
E/AndroidRuntime(11593):        at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(11593):        at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime(11593):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
E/AndroidRuntime(11593):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
E/AndroidRuntime(11593):        at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(11593): Caused by: java.lang.NullPointerException
E/AndroidRuntime(11593):        at kaljurand_at_gmail_dot_com.diktofon.activity.RecordingListActivity.a(Unknown Source)
E/AndroidRuntime(11593):        at kaljurand_at_gmail_dot_com.diktofon.activity.RecordingListActivity.onActivityResult(Unknown Source)
E/AndroidRuntime(11593):        at android.app.Activity.dispatchActivityResult(Activity.java:5423)
E/AndroidRuntime(11593):        at android.app.ActivityThread.deliverResults(ActivityThread.java:3385)
E/AndroidRuntime(11593):        ... 11 more
W/ActivityManager(  684):   Force finishing activity kaljurand_at_gmail_dot_com.diktofon/.activity.RecordingListActivity

The crash appears to be in the method RecordingListActivity.addRecording(File file)

I use the internal recorder mode MY_ACTIVITY_RECORD_SOUND

It looks like the argument file is already checked for null in onActivityResult

Maybe mRecordings == null because the AsyncTask for loadRecordingsInBackground hasn't finished?

Kaljurand commented 9 years ago

Thanks. I'm aware that there are some issues with loading the recordings in the background, and these seem to show up more with newer versions of Android. I think the loading should be redesigned, but I won't have time in the coming weeks to look into it.