I am currently developing a pdf reader app and I want the app to display the current reading page Incase the App is closed and reopened again.
I’m using this dependency
implementation ‘com.github.barteksc:android-pdf-viewer:3.2.0-beta.1’
Question posted in Android Studio
The official documentation can be found here.
The official documentation can be found here.
2
Answers
Here is Kotlin’s help, Save your page number in SharedPreferences in
onDestroy()
. When you open your app Then get the page number from SharedPreferences and load pdf.MainActivity.kt
You can do this with simple logic.
Assuming this is an offline or online application. Each time you load a pdf page, you can get the page number each time the user opens a new page or goes back to previous page. You can store this page when the
onDestroy()
or the ‘onStop()’ method is called.You can store the page information using:
Each time the
onResume()
method is called, you can fetch the last page information and pass it to the pdf loader or WebView and it will load the page number. In case the page information cannot be retrieved, you can then load the first page of the pdf.