Get notified/receive explicit intents when an activity starts
<p>I am developing an application that gets notified when an <code>Activity</code> chosen by a user is started. For this to work, the best approach would be to register a <code>BroadcastReceiver</code> for <code>ACTION_MAIN</code> explicit <code>Intent</code>s, which as far as I know doesn't work (because these <code>Intent</code>s have specific targets). Another, probably less efficient approach, is to use the system <code>ActivityManager</code> and poll on the <code>getRunningTask()</code> which returns a list of all running tasks at the moment. The polling can be done by a background service. By monitoring the changes in this list, I can see whether an activity is running or not, so that my application can get notified. The downside is of course the polling. I have not tried this yet, but I think that this last approach will probably work.</p>

<p>Does anyone know of a better approach(es) or suggestions which are less intensive?</p>
