Determining the current foreground application from a background task or service
With regards to “2. How my background application can know what the application currently running in the foreground is.” Do NOT use the getRunningAppProcesses() method as this returns all sorts of system rubbish from my experience and you’ll get multiple results which have RunningAppProcessInfo.IMPORTANCE_FOREGROUND. Use getRunningTasks() instead This is the code I use in my … Read more