Skip to content
This repository was archived by the owner on Jun 22, 2023. It is now read-only.
This repository was archived by the owner on Jun 22, 2023. It is now read-only.

Advanced Android: [Lesson 13.1][Step 1.5][save current position] #45

Description

@BartekBlachura

Describe the problem
The example says to save current position like this:

@Override
protected void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);

   outState.putInt(PLAYBACK_TIME, mVideoView.getCurrentPosition());
}

but onSaveInstanceState call comes after onPause, so mVideoView.getCurrentPosition() is 0.
I think it will be better:

@Override
    protected void onPause() {
        super.onPause();
        currentPosition = videoView.getCurrentPosition();
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
            videoView.pause();
        }
    }

@Override
    protected void onSaveInstanceState(@NonNull Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putInt(PLAYBACK_TIME, currentPosition);
    }

In which lesson and step of the codelab can this issue be found?
Lesson number + step number. (e.g., Lesson 13.1, Step 1.5)

Versions
Android Studio Dolphin | 2021.3.1 Patch 1
problem found on API 28

codelab: advanced-android

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions