Okey, this is my problem. I have one service class where Ive managed to create media player to play music in background all time. Here is code:
package com.t
Try following to stop the background music at HOME or BACK press.
@Override
protected void onStop() {
super.onStop();
ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
List services = activityManager
.getRunningTasks(Integer.MAX_VALUE);
boolean isActivityFound = false;
if (services.get(0).topActivity.getPackageName().toString()
.equalsIgnoreCase(getPackageName().toString())) {
isActivityFound = true; // Activity belongs to your app is in foreground.
}
if (!isActivityFound) {
if (player != null && player.isPlaying()) {
player.release();
}
}
}