Example usage for android.content Intent ACTION_INSERT

List of usage examples for android.content Intent ACTION_INSERT

Introduction

In this page you can find the example usage for android.content Intent ACTION_INSERT.

Prototype

String ACTION_INSERT

To view the source code for android.content Intent ACTION_INSERT.

Click Source Link

Document

Activity Action: Insert an empty item into the given container.

Usage

From source file:edu.cmu.cylab.starslinger.view.HomeActivity.java

private void showAddContact(String name) {
    Intent intent = new Intent(Intent.ACTION_INSERT);
    intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
        // TODO: determine if still works on 4.4.2 android devices
        // Fix for 4.0.3
        intent.putExtra("finishActivityOnSaveCompleted", true);
    }/*w w w  .  j  ava 2s  .co m*/
    if (!TextUtils.isEmpty(name)) {
        intent.putExtra(ContactsContract.Intents.Insert.NAME, name);
    }
    boolean actionAvailable = getPackageManager().resolveActivity(intent, 0) != null;
    if (actionAvailable) {
        startActivityForResult(intent, RESULT_PICK_CONTACT_SENDER);
    } else {
        showNote(SafeSlinger.getUnsupportedFeatureString("Insert Contact"));
    }
}