I don't want to allow application to run in background. As user press Home button on android device, current activity should be finished.
Or when application is resumed, I would like to know that application has come foreground.
I have created receiver in the <application> tag in the manifest file:
<receiver
android:name=".HomeKeyReceiver"
android:enabled="true"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</receiver>
Still this receiver is not getting called. If this receiver is called then I can close application.