Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -269,41 +269,53 @@ 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) {
@Override
public boolean onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == REQUEST_OPEN_EXISTING_CONTACT || requestCode == REQUEST_OPEN_CONTACT_FORM) {
try {
Uri ur = intent.getData();
finishWithResult(getContactByIdentifier(ur.getLastPathSegment()));
Uri ur = intent.getData();
finishWithResult(getContactByIdentifier(ur.getLastPathSegment()));
} catch (NullPointerException e) {
finishWithResult(FORM_OPERATION_CANCELED);
finishWithResult(FORM_OPERATION_CANCELED);
}
return true;
}
}

if (requestCode == REQUEST_OPEN_CONTACT_PICKER) {
if (resultCode == RESULT_CANCELED) {
finishWithResult(FORM_OPERATION_CANCELED);
return true;
if (requestCode == REQUEST_OPEN_CONTACT_PICKER) {
try {
if (resultCode == RESULT_CANCELED || intent == null) {
finishWithResult(FORM_OPERATION_CANCELED);
return true;
}

Uri contactUri = intent.getData();
if (contactUri == null) {
finishWithResult(FORM_OPERATION_CANCELED);
return true;
}

Cursor 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);
}
if (cursor != null) {
cursor.close();
}
} catch (Exception e) {
Log.e(LOG_TAG, "Error in contact picker: " + e.getMessage());
finishWithResult(FORM_OPERATION_CANCELED);
}
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();
return true;
}

finishWithResult(FORM_COULD_NOT_BE_OPEN);
return false;
}

finishWithResult(FORM_COULD_NOT_BE_OPEN);
return false;
}

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