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:com.forktech.cmerge.ui.ContactsListFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    // Sends a request to the People app to display the create contact
    // screen// w  w w.j a va 2 s. com
    case R.id.menu_add_contact:
        final Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
        startActivity(intent);
        break;
    // For platforms earlier than Android 3.0, triggers the search activity
    case R.id.menu_search:
        if (!Utils.hasHoneycomb()) {
            getActivity().onSearchRequested();
        }
        break;
    case R.id.submit:
        mergeContacts();
        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.money.manager.ex.home.HomeFragment.java

@Subscribe
public void onEvent(AmountEnteredEvent event) {
    QueryAccountBills account = this.getAccountBeingBalanced();
    Money currentBalance = MoneyFactory.fromDouble(account.getTotal());

    // calculate the diff.
    Money newBalance = event.amount;//from  ww w.  j  av  a  2 s  .  c om
    if (newBalance.compareTo(currentBalance) == 0)
        return;

    Money difference;
    TransactionTypes transactionType;

    if (newBalance.compareTo(currentBalance) > 0) {
        // new balance > current balance
        difference = newBalance.subtract(currentBalance);
        transactionType = TransactionTypes.Deposit;
    } else {
        // new balance < current balance
        difference = currentBalance.subtract(newBalance);
        transactionType = TransactionTypes.Withdrawal;
    }

    // open a new transaction screen to create a transaction to balance to the entered amount.
    Intent intent = new Intent(getContext(), CheckingTransactionEditActivity.class);
    intent.setAction(Intent.ACTION_INSERT);
    // add balance and transaction type and payee
    IntentDataParameters params = new IntentDataParameters();
    params.accountName = account.getAccountName();
    params.transactionType = transactionType;
    params.payeeName = getContext().getString(R.string.balance_adjustment);
    params.amount = difference;
    params.categoryName = getContext().getString(R.string.cash);
    intent.setData(params.toUri());

    getContext().startActivity(intent);
}

From source file:com.granita.tasks.TaskListActivity.java

@Override
public void onAddNewTask() {
    Intent editTaskIntent = new Intent(Intent.ACTION_INSERT);
    editTaskIntent.setData(Tasks.getContentUri(mAuthority));
    startActivityForResult(editTaskIntent, REQUEST_CODE_NEW_TASK);
}

From source file:org.alfresco.mobile.android.application.fragments.user.UserProfileFragment.java

public static void actionAddContact(FragmentActivity activity, Person member) {
    if (member != null) {
        final Intent intent = new Intent(Intent.ACTION_INSERT);
        intent.setType(ContactsContract.Contacts.CONTENT_TYPE);

        // ABOUT Information
        intent.putExtra(ContactsContract.Intents.Insert.NAME,
                member.getLastName() + " " + member.getFirstName());

        // JOB TITLE
        intent.putExtra(ContactsContract.Intents.Insert.JOB_TITLE, member.getJobTitle());

        // CONTACT PHONE
        intent.putExtra(ContactsContract.Intents.Insert.PHONE, member.getTelephoneNumber());
        intent.putExtra(ContactsContract.Intents.Insert.PHONE_ISPRIMARY, true);
        intent.putExtra(ContactsContract.Intents.Insert.PHONE_TYPE,
                ContactsContract.CommonDataKinds.Phone.TYPE_MAIN);
        intent.putExtra(ContactsContract.Intents.Insert.SECONDARY_PHONE, member.getMobileNumber());
        intent.putExtra(ContactsContract.Intents.Insert.SECONDARY_PHONE_TYPE,
                ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE);

        // CONTACT EMAIL
        intent.putExtra(ContactsContract.Intents.Insert.EMAIL, member.getEmail());
        intent.putExtra(ContactsContract.Intents.Insert.EMAIL_TYPE,
                ContactsContract.CommonDataKinds.Email.TYPE_WORK);

        // CONTACT IM
        if (member.getSkypeId() != null && member.getSkypeId().length() > 0) {
            intent.putExtra(ContactsContract.Intents.Insert.IM_HANDLE, member.getSkypeId());
            intent.putExtra(ContactsContract.Intents.Insert.IM_PROTOCOL,
                    ContactsContract.CommonDataKinds.Im.PROTOCOL_SKYPE);
        }/*from  w w w . j a v  a2  s. c  o m*/
        if (member.getGoogleId() != null && member.getGoogleId().length() > 0) {
            intent.putExtra(ContactsContract.Intents.Insert.IM_HANDLE, member.getGoogleId());
            intent.putExtra(ContactsContract.Intents.Insert.IM_PROTOCOL,
                    ContactsContract.CommonDataKinds.Im.PROTOCOL_GOOGLE_TALK);
        } else if (member.getInstantMessageId() != null && member.getInstantMessageId().length() > 0) {
            intent.putExtra(ContactsContract.Intents.Insert.IM_HANDLE, member.getInstantMessageId());
        }

        // COMPANY DETAILS
        intent.putExtra(ContactsContract.Intents.Insert.COMPANY, member.getCompany().getName());

        intent.putExtra(ContactsContract.Intents.Insert.SECONDARY_EMAIL, member.getCompany().getEmail());
        intent.putExtra(ContactsContract.Intents.Insert.SECONDARY_EMAIL_TYPE,
                ContactsContract.CommonDataKinds.Email.TYPE_OTHER);

        intent.putExtra(ContactsContract.Intents.Insert.TERTIARY_PHONE,
                member.getCompany().getTelephoneNumber());
        intent.putExtra(ContactsContract.Intents.Insert.TERTIARY_PHONE_TYPE,
                ContactsContract.CommonDataKinds.Phone.TYPE_COMPANY_MAIN);

        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        try {
            if (intent.resolveActivity(activity.getPackageManager()) == null) {
                AlfrescoNotificationManager.getInstance(activity).showAlertCrouton((FragmentActivity) activity,
                        activity.getString(R.string.feature_disable));
                return;
            }

            activity.startActivity(Intent.createChooser(intent, activity.getString(R.string.contact_add)));

            AnalyticsHelper.reportOperationEvent(activity, AnalyticsManager.CATEGORY_USER,
                    AnalyticsManager.ACTION_ADD_CONTACT, AnalyticsManager.LABEL_CONTACT, 1, false);
        } catch (ActivityNotFoundException e) {

        }
    }
}

From source file:org.alfresco.mobile.android.application.fragments.person.PersonProfileFragment.java

public static void actionAddContact(Context c, Person member) {
    if (member != null) {
        final Intent intent = new Intent(Intent.ACTION_INSERT);
        intent.setType(ContactsContract.Contacts.CONTENT_TYPE);

        // ABOUT Information
        intent.putExtra(ContactsContract.Intents.Insert.NAME,
                member.getLastName() + " " + member.getFirstName());

        // JOB TITLE
        intent.putExtra(ContactsContract.Intents.Insert.JOB_TITLE, member.getJobTitle());

        // CONTACT PHONE
        intent.putExtra(ContactsContract.Intents.Insert.PHONE, member.getTelephoneNumber());
        intent.putExtra(ContactsContract.Intents.Insert.PHONE_ISPRIMARY, true);
        intent.putExtra(ContactsContract.Intents.Insert.PHONE_TYPE,
                ContactsContract.CommonDataKinds.Phone.TYPE_MAIN);
        intent.putExtra(ContactsContract.Intents.Insert.SECONDARY_PHONE, member.getMobileNumber());
        intent.putExtra(ContactsContract.Intents.Insert.SECONDARY_PHONE_TYPE,
                ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE);

        // CONTACT EMAIL
        intent.putExtra(ContactsContract.Intents.Insert.EMAIL, member.getEmail());
        intent.putExtra(ContactsContract.Intents.Insert.EMAIL_TYPE,
                ContactsContract.CommonDataKinds.Email.TYPE_WORK);

        // CONTACT IM
        if (member.getSkypeId() != null && member.getSkypeId().length() > 0) {
            intent.putExtra(ContactsContract.Intents.Insert.IM_HANDLE, member.getSkypeId());
            intent.putExtra(ContactsContract.Intents.Insert.IM_PROTOCOL,
                    ContactsContract.CommonDataKinds.Im.PROTOCOL_SKYPE);
        }//from  ww w  .  ja  va  2s.  c  o m
        if (member.getGoogleId() != null && member.getGoogleId().length() > 0) {
            intent.putExtra(ContactsContract.Intents.Insert.IM_HANDLE, member.getGoogleId());
            intent.putExtra(ContactsContract.Intents.Insert.IM_PROTOCOL,
                    ContactsContract.CommonDataKinds.Im.PROTOCOL_GOOGLE_TALK);
        } else if (member.getInstantMessageId() != null && member.getInstantMessageId().length() > 0) {
            intent.putExtra(ContactsContract.Intents.Insert.IM_HANDLE, member.getInstantMessageId());
        }

        // COMPANY DETAILS
        intent.putExtra(ContactsContract.Intents.Insert.COMPANY, member.getCompany().getName());

        intent.putExtra(ContactsContract.Intents.Insert.SECONDARY_EMAIL, member.getCompany().getEmail());
        intent.putExtra(ContactsContract.Intents.Insert.SECONDARY_EMAIL_TYPE,
                ContactsContract.CommonDataKinds.Email.TYPE_OTHER);

        intent.putExtra(ContactsContract.Intents.Insert.TERTIARY_PHONE,
                member.getCompany().getTelephoneNumber());
        intent.putExtra(ContactsContract.Intents.Insert.TERTIARY_PHONE_TYPE,
                ContactsContract.CommonDataKinds.Phone.TYPE_COMPANY_MAIN);

        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        try {
            c.startActivity(Intent.createChooser(intent, c.getString(R.string.contact_add)));
        } catch (ActivityNotFoundException e) {

        }
    }
}

From source file:com.nononsenseapps.notepad.MainActivity.java

@Override
protected void onNewIntent(Intent intent) {
    // Search/*from   ww w.  ja  v  a 2s.  co  m*/
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        // list.onQueryTextChange(query);
        NotesListFragment list = getLeftFragment();
        if (list != null && list.mSearchView != null) {
            list.mSearchView.setQuery(query, false);
        } else if (list != null) {
            list.onQueryTextSubmit(query);
        }
        // Edit or View a list or a note.
    } else if (Intent.ACTION_EDIT.equals(intent.getAction()) || Intent.ACTION_VIEW.equals(intent.getAction())) {
        handleEditIntent(intent);
    } else if (Intent.ACTION_INSERT.equals(intent.getAction())) {
        handleInsertIntent(intent);
    } else if (Intent.ACTION_SEND.equals(intent.getAction())) {
        handleInsertIntent(intent);
    } else if (getString(R.string.complete_note_broadcast_intent).equals(intent.getAction())) {
        // Sent from lock-screen widget on 4.2 and above.
        // Send complete broadcast and finish
        long noteId = NotesEditorFragment.getIdFromUri(intent.getData());
        // This will complete the note
        if (noteId > -1) {
            Intent bintent = new Intent(this, NotePadBroadcastReceiver.class);
            bintent.setAction(getString(R.string.complete_note_broadcast_intent));
            bintent.putExtra(NotePad.Notes._ID, noteId);
            Log.d(TAG, "Sending complete broadcast");
            sendBroadcast(bintent);

            openNoteFragment(intent);

            // Toast.makeText(this, getString(R.string.completed),
            // Toast.LENGTH_SHORT).show();
        }
    } else {
        // Open a note
        if (noteIdToSelect > -1 && currentContent == CONTENTVIEW.DUAL) {
            Bundle arguments = new Bundle();
            arguments.putLong(NotesEditorFragment.KEYID, noteIdToSelect);
            NotesEditorFragment fragment = new NotesEditorFragment();
            fragment.setArguments(arguments);
            getFragmentManager().beginTransaction().replace(R.id.rightFragment, fragment).commit();
            noteIdToSelect = -1;
        }
    }
}

From source file:com.silentcircle.contacts.group.GroupEditorFragment.java

/**
 * Saves or creates the group based on the mode, and if successful
 * finishes the activity. This actually only handles saving the group name.
 * @return true when successful/*from w ww  .  ja  v  a 2  s . co  m*/
 */
public boolean save() {
    if (!hasValidGroupName() || mStatus != Status.EDITING) {
        return false;
    }

    // If we are about to close the editor - there is no need to refresh the data
    getLoaderManager().destroyLoader(LOADER_EXISTING_MEMBERS);

    // If there are no changes, then go straight to onSaveCompleted()
    if (!hasNameChange() && !hasMembershipChange()) {
        onSaveCompleted(false, mGroupUri);
        return true;
    }

    mStatus = Status.SAVING;

    Activity activity = getActivity();
    // If the activity is not there anymore, then we can't continue with the save process.
    if (activity == null) {
        return false;
    }
    Intent saveIntent = null;
    if (Intent.ACTION_INSERT.equals(mAction)) {
        // Create array of raw contact IDs for contacts to add to the group
        long[] membersToAddArray = convertToArray(mListMembersToAdd);

        // Create the save intent to create the group and add members at the same time
        saveIntent = ScContactSaveService.createNewGroupIntent(activity, mGroupNameView.getText().toString(),
                membersToAddArray, activity.getClass(), GroupEditorActivity.ACTION_SAVE_COMPLETED);
    } else if (Intent.ACTION_EDIT.equals(mAction)) {
        // Create array of raw contact IDs for contacts to add to the group
        long[] membersToAddArray = convertToArray(mListMembersToAdd);

        // Create array of raw contact IDs for contacts to add to the group
        long[] membersToRemoveArray = convertToArray(mListMembersToRemove);

        // Create the update intent (which includes the updated group name if necessary)
        saveIntent = ScContactSaveService.createGroupUpdateIntent(activity, mGroupId, getUpdatedName(),
                membersToAddArray, membersToRemoveArray, activity.getClass(),
                GroupEditorActivity.ACTION_SAVE_COMPLETED);
    } else {
        throw new IllegalStateException("Invalid intent action type " + mAction);
    }
    activity.startService(saveIntent);
    return true;
}

From source file:org.openintents.notepad.NoteEditor.java

/**
 * Return intent data when invoked with/*from   w  w  w. j a va2 s  .  c o  m*/
 * action=android.intent.action.CREATE_SHORTCUT
 */
private void createShortcut() {
    Intent intent = new Intent(Intent.ACTION_INSERT, Notes.CONTENT_URI, getApplicationContext(),
            NoteEditor.class);

    Intent result = new Intent();
    result.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
    result.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
            ShortcutIconResource.fromContext(getApplicationContext(), R.drawable.ic_launcher_notepad));
    result.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.new_note));

    setResult(RESULT_OK, result);

    finish();
}

From source file:com.silentcircle.contacts.activities.ScContactSelectionActivity.java

private void startCreateNewContactActivity() {
    Intent intent = new Intent(Intent.ACTION_INSERT, RawContacts.CONTENT_URI);
    intent.putExtra(ScContactEditorActivity.INTENT_KEY_FINISH_ACTIVITY_ON_SAVE_COMPLETED, true);
    startActivityAndForwardResult(intent);
}

From source file:org.openintents.shopping.ui.ShoppingActivity.java

/**
 * Called when the activity is first created.
 *//*from w  w w . j  ava2  s  .com*/
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    if (debug) {
        Log.d(TAG, "Shopping list onCreate()");
    }

    mSortOrder = PreferenceActivity.getShoppingListSortOrderFromPrefs(this);

    mDistribution.setFirst(MENU_DISTRIBUTION_START, DIALOG_DISTRIBUTION_START);

    // Check whether EULA has been accepted
    // or information about new version can be presented.
    if (false && mDistribution.showEulaOrNewVersion()) {
        return;
    }

    setContentView(R.layout.activity_shopping);

    // mEditItemPosition = -1;

    // Automatic requeries (once a second)
    mUpdateInterval = 2000;
    mUpdating = false;

    // General Uris:
    mListUri = ShoppingContract.Lists.CONTENT_URI;
    mItemUri = ShoppingContract.Items.CONTENT_URI;
    mListItemUri = ShoppingContract.Items.CONTENT_URI;

    int defaultShoppingList = getLastUsedListFromPrefs();

    // Handle the calling intent
    final Intent intent = getIntent();
    final String type = intent.resolveType(this);
    final String action = intent.getAction();

    if (action == null) {
        // Main action
        mState = STATE_MAIN;

        mListUri = Uri.withAppendedPath(ShoppingContract.Lists.CONTENT_URI, "" + defaultShoppingList);

        intent.setData(mListUri);
    } else if (Intent.ACTION_MAIN.equals(action)) {
        // Main action
        mState = STATE_MAIN;

        mListUri = Uri.withAppendedPath(ShoppingContract.Lists.CONTENT_URI, "" + defaultShoppingList);

        intent.setData(mListUri);

    } else if (Intent.ACTION_VIEW.equals(action)) {
        mState = STATE_VIEW_LIST;

        setListUriFromIntent(intent.getData(), type);
    } else if (Intent.ACTION_INSERT.equals(action)) {

        mState = STATE_VIEW_LIST;

        setListUriFromIntent(intent.getData(), type);

    } else if (Intent.ACTION_PICK.equals(action)) {
        mState = STATE_PICK_ITEM;

        mListUri = Uri.withAppendedPath(ShoppingContract.Lists.CONTENT_URI, "" + defaultShoppingList);
    } else if (Intent.ACTION_GET_CONTENT.equals(action)) {
        mState = STATE_GET_CONTENT_ITEM;

        mListUri = Uri.withAppendedPath(ShoppingContract.Lists.CONTENT_URI, "" + defaultShoppingList);
    } else if (GeneralIntents.ACTION_INSERT_FROM_EXTRAS.equals(action)) {
        if (ShoppingListIntents.TYPE_STRING_ARRAYLIST_SHOPPING.equals(type)) {
            /*
             * Need to insert new items from a string array in the intent
            * extras Use main action but add an item to the options menu
            * for adding extra items
            */
            getShoppingExtras(intent);
            mState = STATE_MAIN;
            mListUri = Uri.withAppendedPath(ShoppingContract.Lists.CONTENT_URI, "" + defaultShoppingList);
            intent.setData(mListUri);
        } else if (intent.getDataString().startsWith(ShoppingContract.Lists.CONTENT_URI.toString())) {
            // Somewhat quick fix to pass data from ShoppingListsActivity to
            // this activity.

            // We received a valid shopping list URI:
            mListUri = intent.getData();

            getShoppingExtras(intent);
            mState = STATE_MAIN;
            intent.setData(mListUri);
        }
    } else {
        // Unknown action.
        Log.e(TAG, "Shopping: Unknown action, exiting");
        finish();
        return;
    }

    // hook up all buttons, lists, edit text:
    createView();

    // populate the lists
    fillListFilter();

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    // Get last part of URI:
    int selectList;
    try {
        selectList = Integer.parseInt(mListUri.getLastPathSegment());
    } catch (NumberFormatException e) {
        selectList = defaultShoppingList;
    }

    // select the default shopping list at the beginning:
    setSelectedListId(selectList);

    if (icicle != null) {
        String prevText = icicle.getString(ORIGINAL_ITEM);
        if (prevText != null) {
            mEditText.setTextKeepState(prevText);
        }
        // mTextEntryMenu = icicle.getInt(BUNDLE_TEXT_ENTRY_MENU);
        // mEditItemPosition = icicle.getInt(BUNDLE_CURSOR_ITEMS_POSITION);
        mItemUri = Uri.parse(icicle.getString(BUNDLE_ITEM_URI));
        List<String> pathSegs = mItemUri.getPathSegments();
        int num = pathSegs.size();
        mListItemUri = Uri.withAppendedPath(mListUri, pathSegs.get(num - 1));
        if (icicle.containsKey(BUNDLE_RELATION_URI)) {
            mRelationUri = Uri.parse(icicle.getString(BUNDLE_RELATION_URI));
        }
        mItemsView.mMode = icicle.getInt(BUNDLE_MODE);
        mItemsView.mModeBeforeSearch = icicle.getInt(BUNDLE_MODE_BEFORE_SEARCH);
    }

    // set focus to the edit line:
    mEditText.requestFocus();

    // TODO remove initFromPreferences from onCreate
    // we need it in resume to update after settings have changed
    initFromPreferences();
    // now update title and fill all items
    onModeChanged();

    mItemsView.setActionBarListener(this);
    mItemsView.setUndoListener(this);

    if ("myo".equals(BuildConfig.FLAVOR)) {
        try {
            Class myoToggleBoughtInputMethod = Class
                    .forName("org.openintents.shopping.ui.MyoToggleBoughtInputMethod");
            Constructor constructor = myoToggleBoughtInputMethod
                    .getConstructor(new Class[] { ShoppingActivity.class, mItemsView.getClass() });
            toggleBoughtInputMethod = (ToggleBoughtInputMethod) constructor
                    .newInstance(new Object[] { this, mItemsView });
        } catch (ClassNotFoundException e) {
        } catch (NoSuchMethodException e) {
        } catch (InvocationTargetException e) {
        } catch (InstantiationException e) {
        } catch (IllegalAccessException e) {
        }
    }
}