Question: I am trying to get a list of website pages links. But I have a problem with the URL. The code underneath only gives me links to the first page.

```
import requests
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

page = 1
while page != 6:
      url = f"https://www.autocentrum.pl/stacje-paliw/?strona-{page}/?s=5&order=&q="
      print(url)
      page = page + 1

```

Any ideas how to change the url to fix it?

Answer: 
If you have multiple activities while user is running the application, use `LifecycleObserver` to observe the state change in application class.

```
implementation "androidx.lifecycle:lifecycle-extensions:2.4.0"

```

Application Class

```
public class MyApplication extends Application implements LifecycleObserver {

@Override
public void onCreate() {
    super.onCreate();

    ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
}

// Application level lifecycle events

@OnLifecycleEvent(Lifecycle.Event.ON_START)
public void onEnteredForeground() {
    //Log.d(TAG,"Application did enter foreground");
}

@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
public void onEnteredBackground() {
   // Log.d(TAG,"Application did enter background");
}

}

```

For more info refer to - [Handling lifecycle with Lifecycle Observers](https://developer.android.com/topic/libraries/architecture/lifecycle?authuser=1)
use onPause() then make it stop playing music, after that onResume or onStart to play the music if user is back to app