Skip to content
This repository has been 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

Open
BartekBlachura opened this issue Jan 4, 2023 · 0 comments
Open

Comments

@BartekBlachura
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant