From f217fa0b732d612524508aca09f2d42ac7a74d4d Mon Sep 17 00:00:00 2001 From: Ingo Kodba Date: Mon, 4 May 2026 12:00:35 +0200 Subject: [PATCH] fix: open correct contact when reopening details after a call The contact details intent (ACTION_QUICK_CONTACT) was launched with only FLAG_ACTIVITY_NEW_TASK. If the system Contacts app's task was still alive from a previous view (e.g. after calling the previously-viewed contact), that task was brought forward with its old activity and the new intent was dropped. Adds FLAG_ACTIVITY_CLEAR_TASK so the receiver's task is cleared before launching the new view. Fixes FossifyOrg/Phone#783. --- .../org/fossify/phone/extensions/ActivityExt.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/org/fossify/phone/extensions/ActivityExt.kt b/app/src/main/kotlin/org/fossify/phone/extensions/ActivityExt.kt index 3a2bd0ccd..1ea82cc36 100644 --- a/app/src/main/kotlin/org/fossify/phone/extensions/ActivityExt.kt +++ b/app/src/main/kotlin/org/fossify/phone/extensions/ActivityExt.kt @@ -6,7 +6,6 @@ import android.net.Uri import android.provider.ContactsContract import org.fossify.commons.extensions.isPackageInstalled import org.fossify.commons.extensions.launchActivityIntent -import org.fossify.commons.extensions.launchViewContactIntent import org.fossify.commons.helpers.CONTACT_ID import org.fossify.commons.helpers.FIRST_CONTACT_ID import org.fossify.commons.helpers.IS_PRIVATE @@ -51,6 +50,9 @@ fun Activity.startContactDetailsIntent(contact: Contact) { ContactsContract.Contacts.CONTENT_LOOKUP_URI, "vnd.android.cursor.dir/person" ) + // launchActivityIntent adds FLAG_ACTIVITY_NEW_TASK; without CLEAR_TASK the receiving + // app's existing task is brought forward and re-shows its previously-viewed contact. + addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK) launchActivityIntent(this) } } else { @@ -60,7 +62,12 @@ fun Activity.startContactDetailsIntent(contact: Contact) { val publicUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey) runOnUiThread { - launchViewContactIntent(publicUri) + Intent().apply { + action = ContactsContract.QuickContact.ACTION_QUICK_CONTACT + data = publicUri + addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK) + launchActivityIntent(this) + } } } }