Skip to content

Random NullPointerException #61

Description

@dexpota

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();
                }
            }
        });
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions