1

I have used the custom SeekBar in the VideoViewin the RecyclerView list. When i press back button and again start the activity, it throws the Null pointer exception. The NPE is in the Runnable interface and app crashes.

E/AndroidRuntime: FATAL EXCEPTION: main
Process: exoplayer.com.youtubesurfaceviewplayer, PID: 16750
java.lang.NullPointerException
    at adapter.VideoRecyclerAdapter$13$1.run(VideoRecyclerAdapter.java:531)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:149)
    at android.app.ActivityThread.main(ActivityThread.java:5045)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:610)
    at dalvik.system.NativeStart.main(Native Method)

-

Runnable onEverySecond = new Runnable() {
    public void run() {
        long Duration = mediaPlayer.getDuration();//Throws NPE in this line
        long current = mediaPlayer.getCurrentPosition();//Throws NPE in this line
        // Displaying Total Duration time
        lblDuration.setText("" + utils.stringForTime(Duration));
        // Displaying time completed playing
        lblCurrentPosition.setText(utils.stringForTime(current));
        // Updating progress bar
        int progress = (int) (utils.getProgressPercentage(currentDuration, totalDuration));
        long remainingTime = (Duration - current);
        lblRemainingPosition.setText("-"+utils.stringForTime(remainingTime));
        mediacontroller_progress.setProgress(progress);
        // Running this thread after 100 milliseconds
        handler.postDelayed(this, 100);
    }
};
Oleg Khalidov
  • 5,108
  • 1
  • 28
  • 29
Shikha Ratra
  • 697
  • 3
  • 12
  • 28

0 Answers0