Question

I currently have an application that naturally gets pushed to the background when the home key is pressed.

The activity losses focus but continues running in the background.

So I want to know is it possible to bring the application back to the foreground when the user presses the green key (call button) on the device?

Was it helpful?

Solution

There is no way to completely override the call button behaviour without user interaction. When pressing it, the user will be asked to choose between the default action (launching the dialer), or launching your application.

If you wanted to do this, your manifest would look something like this:

<activity android:name=".SomeActivity">
    <intent-filter>
        <action android:name="android.intent.action.CALL_BUTTON" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top