Java Code Examples for android.content.Intent.ACTION_INSERT_OR_EDIT

The following are Jave code examples for showing how to use ACTION_INSERT_OR_EDIT of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: CSipSimple   File: ContactsUtils5.java   View Source Code Vote up 6 votes
@Override
public Intent getAddContactIntent(String displayName, String csipUri) {
    Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT, Contacts.CONTENT_URI);
    intent.setType(Contacts.CONTENT_ITEM_TYPE);

    if (!TextUtils.isEmpty(displayName)) {
        intent.putExtra(Insert.NAME, displayName);
    }

    if (!TextUtils.isEmpty(csipUri)) {
        ArrayList<ContentValues> data = new ArrayList<ContentValues>();
        ContentValues csipProto = new ContentValues();
        csipProto.put(Data.MIMETYPE, CommonDataKinds.Im.CONTENT_ITEM_TYPE);
        csipProto.put(CommonDataKinds.Im.PROTOCOL, CommonDataKinds.Im.PROTOCOL_CUSTOM);
        csipProto.put(CommonDataKinds.Im.CUSTOM_PROTOCOL, SipManager.PROTOCOL_CSIP);
        csipProto.put(CommonDataKinds.Im.DATA, SipUri.getCanonicalSipContact(csipUri, false));
        data.add(csipProto);

        intent.putParcelableArrayListExtra(Insert.DATA, data);
    }

    return intent;
}
 
Example 2
Project: q-mail   File: Contacts.java   View Source Code Vote up 5 votes
/**
 * Start the activity to add a phone number to an existing contact or add a new one.
 *
 * @param phoneNumber
 *         The phone number to add to a contact, or to use when creating a new contact.
 */
public void addPhoneContact(final String phoneNumber) {
    Intent addIntent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
    addIntent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
    addIntent.putExtra(ContactsContract.Intents.Insert.PHONE, Uri.decode(phoneNumber));
    addIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    mContext.startActivity(addIntent);
}
 
Example 3
Project: PeSanKita-android   File: GroupMembersDialog.java   View Source Code Vote up 5 votes
@Override
public void onClick(DialogInterface dialogInterface, int item) {
  Recipient recipient = groupMembers.get(item);

  if (recipient.getContactUri() != null) {
    ContactsContract.QuickContact.showQuickContact(context, new Rect(0,0,0,0),
                                                   recipient.getContactUri(),
                                                   ContactsContract.QuickContact.MODE_LARGE, null);
  } else {
    final Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
    intent.putExtra(ContactsContract.Intents.Insert.PHONE, recipient.getNumber());
    intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
    context.startActivity(intent);
  }
}
 
Example 4
Project: PeSanKita-android   File: ConversationActivity.java   View Source Code Vote up 5 votes
private void handleAddToContacts() {
  try {
    final Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
    intent.putExtra(ContactsContract.Intents.Insert.PHONE, recipients.getPrimaryRecipient().getNumber());
    intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
    startActivityForResult(intent, ADD_CONTACT);
  } catch (ActivityNotFoundException e) {
    Log.w(TAG, e);
  }
}
 
Example 5
Project: Cable-Android   File: GroupMembersDialog.java   View Source Code Vote up 5 votes
@Override
public void onClick(DialogInterface dialogInterface, int item) {
  Recipient recipient = groupMembers.get(item);

  if (recipient.getContactUri() != null) {
    ContactsContract.QuickContact.showQuickContact(context, new Rect(0,0,0,0),
                                                   recipient.getContactUri(),
                                                   ContactsContract.QuickContact.MODE_LARGE, null);
  } else {
    final Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
    intent.putExtra(ContactsContract.Intents.Insert.PHONE, recipient.getNumber());
    intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
    context.startActivity(intent);
  }
}
 
Example 6
Project: Cable-Android   File: ConversationActivity.java   View Source Code Vote up 5 votes
private void handleAddToContacts() {
  try {
    final Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
    intent.putExtra(ContactsContract.Intents.Insert.PHONE, recipients.getPrimaryRecipient().getNumber());
    intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
    startActivityForResult(intent, ADD_CONTACT);
  } catch (ActivityNotFoundException e) {
    Log.w(TAG, e);
  }
}