java.lang.RuntimeException: Unable to pause activity {com.music.test/com.music.test.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.media.MediaPlayer.isPlaying()' on a null object reference

Stack Overflow | Devansh | 7 months ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    onPause() crashes when calling mediaplayer.isPlaying()

    Stack Overflow | 7 months ago | Devansh
    java.lang.RuntimeException: Unable to pause activity {com.music.test/com.music.test.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.media.MediaPlayer.isPlaying()' on a null object reference

    Root Cause Analysis

    1. java.lang.NullPointerException

      Attempt to invoke virtual method 'boolean android.media.MediaPlayer.isPlaying()' on a null object reference

      at com.music.test.MainActivity.onPause()
    2. com.music.test
      MainActivity.onPause
      1. com.music.test.MainActivity.onPause(MainActivity.java:181)
      1 frame
    3. Android Platform
      ActivityThread.performPauseActivity
      1. android.app.Activity.performPause(Activity.java:6397)
      2. android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1380)
      3. android.app.ActivityThread.performPauseActivity(ActivityThread.java:3435)
      3 frames