Android: How do i trigger an app on an event?
<p>Suppose I want to start an app to run in background as soon as an event occurs in the phone.</p>

<p>For example:-</p>

<ol>
<li><p>When I open my gallery I may want to automatically start my app which monitors my file browsing and prepares database for most recent documents, most listened song, etc and is automatically closed when I exit my gallery folder.</p></li>
<li><p>Whenever I open my internet browser I might want to start my app in background, which monitors how many times I visited a particular site and it automatically closes when I close the browser.</p></li>
</ol>
