I wish to have one application that runs in the background, which knows when any of the built-in applications (messaging, contacts, etc) is running.
So my questions
In lollipop and up:
Add to mainfest:
And do something like this:
if( mTaskId < 0 ) { List tasks = mActivityManager.getAppTasks(); if( tasks.size() > 0 ) mTaskId = tasks.get( 0 ).getTaskInfo().id; }