Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ rootProject.allprojects {
apply plugin: 'com.android.library'

android {
namespace 'flutter.plugins.contactsservice.contactsservice'
compileSdkVersion 30

defaultConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ void finishWithResult(Object result) {

@Override
public boolean onActivityResult(int requestCode, int resultCode, Intent intent) {
if(requestCode == REQUEST_OPEN_EXISTING_CONTACT || requestCode == REQUEST_OPEN_CONTACT_FORM) {
if (requestCode == REQUEST_OPEN_EXISTING_CONTACT || requestCode == REQUEST_OPEN_CONTACT_FORM) {
try {
Uri ur = intent.getData();
finishWithResult(getContactByIdentifier(ur.getLastPathSegment()));
Expand All @@ -286,24 +286,35 @@ public boolean onActivityResult(int requestCode, int resultCode, Intent intent)
finishWithResult(FORM_OPERATION_CANCELED);
return true;
}
Uri contactUri = intent.getData();
if (intent != null){
Cursor cursor = contentResolver.query(contactUri, null, null, null, null);
if (cursor.moveToFirst()) {
String id = contactUri.getLastPathSegment();
getContacts("openDeviceContactPicker", id, false, false, false, localizedLabels, this.result);
} else {
Log.e(LOG_TAG, "onActivityResult - cursor.moveToFirst() returns false");
finishWithResult(FORM_OPERATION_CANCELED);
}}else{return true;}
cursor.close();

Cursor cursor = null;

try {
if (intent != null) {
Uri contactUri = intent.getData();
cursor = contentResolver.query(contactUri, null, null, null, null);
if (cursor != null && cursor.moveToFirst()) {
String id = contactUri.getLastPathSegment();
getContacts("openDeviceContactPicker", id, false, false, false, localizedLabels, this.result);
} else {
Log.e(LOG_TAG, "onActivityResult - cursor.moveToFirst() returns false");
finishWithResult(FORM_OPERATION_CANCELED);
}
}
} finally {
if (cursor != null) {
cursor.close();
}
}

return true;
}

finishWithResult(FORM_COULD_NOT_BE_OPEN);
return false;
}


void openExistingContact(Contact contact) {
String identifier = contact.identifier;
try {
Expand Down