Skip to content Skip to sidebar Skip to footer

Android - Play Background Music That Will Play Across All Activities

I have been researching for hours to no avail. I'm trying to implement a simple background music to my app that will play across all activities and pause whenever the app is minimi

Solution 1:

create a base activity and extend all other other activities from base activity and play bg music or whatever you want

publicclassBaseActivtyextendsAppCompatActivity{

@OverrideprotectedvoidonPause() {
        super.onPause();
// pause music
    }

@OverrideprotectedvoidonResume() {
        super.onResume();
// play music
    }
}

publicclassFirstActivtyextendsBaseActivty{

// perform other stuff here
}

hope that will help you...

Post a Comment for "Android - Play Background Music That Will Play Across All Activities"