diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 3b81e346..2083a624 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -94,6 +94,15 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ContactActivity.kt
index 5731397a..73251fd9 100644
--- a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ContactActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ContactActivity.kt
@@ -95,10 +95,16 @@ class ContactActivity : SimpleActivity() {
private fun initContact() {
var contactId = intent.getIntExtra(CONTACT_ID, 0)
- if (contactId == 0 && intent.action == ContactsContract.QuickContact.ACTION_QUICK_CONTACT) {
+ val action = intent.action
+ if (contactId == 0 && (action == ContactsContract.QuickContact.ACTION_QUICK_CONTACT || action == Intent.ACTION_VIEW)) {
val data = intent.data
if (data != null) {
- val rawId = getContactRawId(data) ?: -1
+ val rawId = if (data.path.contains("lookup")) {
+ getLookupUriRawId(data)
+ } else {
+ getContactUriRawId(data)
+ }
+
if (rawId != -1) {
contactId = rawId
}
diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/extensions/Context.kt
index 88ec3d55..c738891a 100644
--- a/app/src/main/kotlin/com/simplemobiletools/contacts/extensions/Context.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/contacts/extensions/Context.kt
@@ -48,20 +48,26 @@ fun Context.sendSMSIntent(recipient: String) {
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
-fun Context.getContactRawId(dataUri: Uri): Int? {
+fun Context.getLookupUriRawId(dataUri: Uri): Int {
val lookupKey = getLookupKeyFromUri(dataUri)
if (lookupKey != null && isLollipopPlus()) {
val uri = lookupContactUri(lookupKey, this)
- val projection = arrayOf(ContactsContract.Contacts.NAME_RAW_CONTACT_ID)
- var cursor: Cursor? = null
- try {
- cursor = contentResolver.query(uri, projection, null, null, null)
- if (cursor.moveToFirst()) {
- return cursor.getIntValue(ContactsContract.Contacts.NAME_RAW_CONTACT_ID)
- }
- } finally {
- cursor?.close()
+ return getContactUriRawId(uri)
+ }
+ return -1
+}
+
+@TargetApi(Build.VERSION_CODES.LOLLIPOP)
+fun Context.getContactUriRawId(uri: Uri): Int {
+ val projection = arrayOf(ContactsContract.Contacts.NAME_RAW_CONTACT_ID)
+ var cursor: Cursor? = null
+ try {
+ cursor = contentResolver.query(uri, projection, null, null, null)
+ if (cursor.moveToFirst()) {
+ return cursor.getIntValue(ContactsContract.Contacts.NAME_RAW_CONTACT_ID)
}
+ } finally {
+ cursor?.close()
}
return -1
}