Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
For my current SIP Phone app I need a special activity, the RingingActivity to be set like this in the manifest:

XML
<activity
    android:name=".ui.RingingActivity"
    android:configChanges="keyboardHidden|orientation|screenSize"
    android:launchMode="singleTask"
    android:persistent="true"
    android:screenOrientation="portrait"
    android:theme="@style/AppTheme.NoActionBar">
</activity>
Where the interesting parts are the launchMode and persistent attributes. The launchMode tells Android, to start a new Task (with a new Backstack) when this activity opens. This is necessary, as I launch it in code with several window flags, like WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED to show the incoming call over the lock screen. Second reason is, it is triggered by an external network event (incoming call).

But here starts my problem:

* A call is incoming. Activity is shown as expected.
* User presses the HOME Button while it is ringing
* I display a notification to signal, there is a ringing call (works perfectly)
* BUT: If the user now clicks the app-icon on desktop again, the dialer activity comes up (and not the ringing activity), because ringing is on its own stack.

So I google'd the docs a bit and found, this
Users must be able to leave a task and then come back to it later using this activity launcher. For this reason, the two launch modes that mark activities as always initiating a task, "singleTask" and "singleInstance", should be used only when the activity has an ACTION_MAIN and a CATEGORY_LAUNCHER filter.


So I changed my manifest accordingly:
XML
<activity
    android:name=".ui.RingingActivity"
    android:configChanges="keyboardHidden|orientation|screenSize"
    android:launchMode="singleTask"
    android:persistent="true"
    android:screenOrientation="portrait"
    android:theme="@style/AppTheme.NoActionBar">
    <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
    </intent-filter>
</activity>

and I added the intent filter. Now my app has two activities with this MAIN/LAUNCHER intent filter. And still it opens the dialer when I click the icon on desktop.

I like to add, that, once the icon got clicked, not even the notification is able to bring back the RingingActivity! The dialer Task is on front and nothing can change this (it seems). The ringing is in background, still ringing but no way to make it visible again.

How can I choose a specific task when the app icon is clicked? How can I manually/programmatically tell Android, to bring the ringing task to front, if it exists?

Thanks in advance!

What I have tried:

I tried the android:allowTaskReparenting attribute. While this does _almost_ what I want, it still kills the underlying Activities in the main stack.

I just want the ringing activity to be on front, to be reparented to the main task and put on top of it (not cleaning it).
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900