Android examples for App:Popular App
is Spotify Running
import android.app.ActivityManager; import android.content.Context; import android.content.Intent; import java.util.List; public class Main{ private static final String SPOTIFY_APP_PACKAGE = "com.spotify.music"; public static boolean isSpotifyRunning(Context context) { ActivityManager activityManager = (ActivityManager) context .getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningAppProcessInfo> procInfos = activityManager .getRunningAppProcesses(); for (int i = 0; i < procInfos.size(); i++) { if (procInfos.get(i).processName.equals(SPOTIFY_APP_PACKAGE)) { return true; }//from ww w . j a v a 2 s . com } return false; } }