adrielcafe / AndroidAudioRecorder

A fancy audio recorder lib for Android. Supports WAV format at 48kHz.
1.63k stars 380 forks source link

Random NullPointerException #61

Open dexpota opened 5 years ago

dexpota commented 5 years ago

I am using AudioRecorderActivity and sometimes it crashes because the attribute saveMenuItem is null, the following is the exception launched:

2019-03-20 10:24:16.431 3586-3586/it.egate.intesi.eroi E/AndroidRuntime: FATAL EXCEPTION: main
    Process: it.egate.intesi.eroi, PID: 3586
    java.lang.NullPointerException: Attempt to invoke interface method 'android.view.MenuItem android.view.MenuItem.setVisible(boolean)' on a null object reference
        at cafe.adriel.androidaudiorecorder.AudioRecorderActivity.resumeRecording(AudioRecorderActivity.java:268)
        at cafe.adriel.androidaudiorecorder.AudioRecorderActivity.access$200(AudioRecorderActivity.java:33)
        at cafe.adriel.androidaudiorecorder.AudioRecorderActivity$1.run(AudioRecorderActivity.java:223)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:

From what I can see the problem arise when the method is called from the callback defined intoggleRecording

    public void toggleRecording(View v) {
        stopPlaying();
        Util.wait(100, new Runnable() {
            @Override
            public void run() {
                if (isRecording) {
                    pauseRecording();
                } else {
                    resumeRecording();
                }
            }
        });
    }
abhijitca commented 5 years ago

Please fix this Issue ASAP, My application became to buggy on this exception.

Ratzz30 commented 5 years ago

I have Encountered with same error MenuItem.setVisible is null Please the Fix Issue Asap. and I tried Manually to change MenuItem to ImageButton It Worked But I am unable to get the response OnActivityResult method. it would appreciated if you guys can fix this issue as soon as possible. Thanks In advance.