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.silentcircle.contacts.editor.ContactEditorFragment.java

private void saveDefaultAccountIfNecessary() {
    // Verify that this is a newly created contact, that the contact is composed of only
    // 1 raw contact, and that the contact is not a user profile.
    if (!Intent.ACTION_INSERT.equals(mAction) && mState.size() == 1 && !isEditingUserProfile()) {
        return;// ww w. j  a  v  a2s.  com
    }

    // Find the associated account for this contact (retrieve it here because there are
    // multiple paths to creating a contact and this ensures we always have the correct
    // account).
    final RawContactDelta rawContactDelta = mState.get(0);
    mEditorUtils.saveDefaultAndAllAccounts();
}

From source file:cz.maresmar.sfm.view.MainActivity.java

@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
    switch (view.getId()) {
    case TODAY_DRAWER_ID:
        showOrResetToday();/*from  w w w  .  ja va2 s  .  co m*/
        mDrawer.closeDrawer();
        return true;
    case DAY_DRAWER_ID:
        showOrResetDayPager();
        mDrawer.closeDrawer();
        return true;
    case ADD_PORTAL_DRAWER_ID:
        startLoginListActivity(Intent.ACTION_INSERT);
        return true;
    case MANAGE_PORTAL_DRAWER_ID:
        startLoginListActivity(Intent.ACTION_VIEW);
        return true;
    case ORDERS_DRAWER_ID:
        showOrResetOrders();
        mDrawer.closeDrawer();
        return true;
    case FEEDBACK_DRAWER_ID:
        startSendFeedback();
        mDrawer.closeDrawer();
        return true;
    case SETTINGS_DRAWER_ID:
        startSettingsActivity();
        mDrawer.closeDrawer();
        return true;
    case HELP_DRAWER_ID:
        startHelpActivity();
        mDrawer.closeDrawer();
        return true;
    case ABOUT_DRAWER_ID:
        SfmApp.startAboutActivity(this);
        mDrawer.closeDrawer();
        return true;
    default: {
        if (drawerItem.getTag() != null && (int) drawerItem.getTag() == PORTAL_ITEM_DRAWER_TAG) {
            showOrResetPortalPager(drawerItem.getIdentifier());
            mDrawer.closeDrawer();
            return true;
        } else {
            return false;
        }
    }
    }
}

From source file:com.money.manager.ex.common.CategoryListFragment.java

private void showSearchActivityFor(SearchParameters parameters) {
    Intent intent = new Intent(getActivity(), SearchActivity.class);
    intent.putExtra(SearchActivity.EXTRA_SEARCH_PARAMETERS, Parcels.wrap(parameters));
    intent.setAction(Intent.ACTION_INSERT);
    startActivity(intent);/*from   w  ww  . ja  va 2 s  .  co m*/
}

From source file:com.silentcircle.contacts.editor.ContactEditorFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    // This supports the keyboard shortcut to save changes to a contact but shouldn't be visible
    // because the custom action bar contains the "save" button now (not the overflow menu).
    // TODO: Find a better way to handle shortcuts, i.e. onKeyDown()?
    final MenuItem doneMenu = menu.findItem(R.id.menu_done);
    //        final MenuItem splitMenu = menu.findItem(R.id.menu_split);
    //        final MenuItem joinMenu = menu.findItem(R.id.menu_join);
    final MenuItem helpMenu = menu.findItem(R.id.menu_help);

    // Set visibility of menus
    doneMenu.setVisible(false);/*  w ww . ja  va  2 s.  c o m*/

    //        // Split only if more than one raw profile and not a user profile
    //        splitMenu.setVisible(mState != null && mState.size() > 1 && !isEditingUserProfile());
    //
    //        // Cannot join a user profile
    //        joinMenu.setVisible(!isEditingUserProfile());

    // help menu depending on whether this is inserting or editing
    if (Intent.ACTION_INSERT.equals(mAction)) {
        // inserting
        HelpUtils.prepareHelpMenuItem(mContext, helpMenu, R.string.help_url_people_add);
    } else if (Intent.ACTION_EDIT.equals(mAction)) {
        // editing
        HelpUtils.prepareHelpMenuItem(mContext, helpMenu, R.string.help_url_people_edit);
    } else {
        // something else, so don't show the help menu
        helpMenu.setVisible(false);
    }

    int size = menu.size();
    for (int i = 0; i < size; i++) {
        menu.getItem(i).setEnabled(mEnabled);
    }
}

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

/**
 * Returns true the intent URI targets a note. Either an edit/view or
 * insert.//from   w ww.j  av a2  s. co m
 */
boolean isNoteIntent(final Intent intent) {
    if (intent == null) {
        return false;
    }
    if (Intent.ACTION_SEND.equals(intent.getAction())
            || "com.google.android.gm.action.AUTO_SEND".equals(intent.getAction())) {
        return true;
    }

    if (intent.getData() != null
            && (Intent.ACTION_EDIT.equals(intent.getAction()) || Intent.ACTION_VIEW.equals(intent.getAction())
                    || Intent.ACTION_INSERT.equals(intent.getAction()))
            && (intent.getData().getPath().startsWith(LegacyDBHelper.NotePad.Notes.PATH_VISIBLE_NOTES)
                    || intent.getData().getPath().startsWith(LegacyDBHelper.NotePad.Notes.PATH_NOTES)
                    || intent.getData().getPath().startsWith(Task.URI.getPath()))
            && !intent.getData().getPath().startsWith(TaskList.URI.getPath())) {
        return true;
    }

    return false;
}

From source file:com.android.contacts.activities.DialtactsActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.dialtacts_options, menu);

    // set up intents and onClick listeners
    final MenuItem callSettingsMenuItem = menu.findItem(R.id.menu_call_settings);
    final MenuItem searchMenuItem = menu.findItem(R.id.search_on_action_bar);
    final MenuItem filterOptionMenuItem = menu.findItem(R.id.filter_option);
    final MenuItem addContactOptionMenuItem = menu.findItem(R.id.add_contact);

    callSettingsMenuItem.setIntent(DialtactsActivity.getCallSettingsIntent());
    searchMenuItem.setOnMenuItemClickListener(mSearchMenuItemClickListener);
    filterOptionMenuItem.setOnMenuItemClickListener(mFilterOptionsMenuItemClickListener);
    addContactOptionMenuItem.setIntent(new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI));

    return true;/* w  w w  .  j a  v a 2s  .  c  o  m*/
}

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

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override//from   w ww. j a  va 2 s.  com
public void addTaskInList(final String text, final long listId) {
    if (listId < 1) {
        // Cant add to invalid lists
        return;
    }
    final Intent intent = new Intent().setAction(Intent.ACTION_INSERT).setClass(this, ActivityMain_.class)
            .setData(Task.URI).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
            .putExtra(TaskDetailFragment.ARG_ITEM_LIST_ID, listId);
    if (fragment2 != null) {
        // Set intent to preserve state when rotating
        setIntent(intent);
        // Replace editor fragment
        getSupportFragmentManager().beginTransaction()
                .setCustomAnimations(R.anim.slide_in_top, R.anim.slide_out_bottom)
                .replace(R.id.fragment2, TaskDetailFragment_.getInstance(text, listId))
                .commitAllowingStateLoss();
        taskHint.setVisibility(View.GONE);
    } else {
        // Open an activity

        // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        // Log.d("nononsenseapps animation", "Animating");
        // intent.putExtra(ANIMATEEXIT, true);
        // startActivity(
        // intent,
        // ActivityOptions.makeCustomAnimation(this,
        // R.anim.activity_slide_in_left,
        // R.anim.activity_slide_out_left).toBundle());
        // }
        // else {
        startActivity(intent);
        // }
    }
}

From source file:com.android.contacts.activities.PeopleActivity.java

@Override
public void onClick(View view) {
    switch (view.getId()) {
    case R.id.floating_action_button:
        Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            intent.putExtras(extras);/*from w w  w.j a v a2s.  c om*/
        }
        try {
            ImplicitIntentsUtil.startActivityInApp(PeopleActivity.this, intent);
        } catch (ActivityNotFoundException ex) {
            Toast.makeText(PeopleActivity.this, R.string.missing_app, Toast.LENGTH_SHORT).show();
        }
        break;
    default:
        Log.wtf(TAG, "Unexpected onClick event from " + view);
    }
}

From source file:com.android.mms.ui.ComposeMessageActivity.java

private void addEventToCalendar(String subject, String description) {
    Intent calendarIntent = new Intent(Intent.ACTION_INSERT);
    Calendar calTime = Calendar.getInstance();
    calendarIntent.setType(CALENDAR_EVENT_TYPE);
    calendarIntent.putExtra(Events.TITLE, subject);
    calendarIntent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, calTime.getTimeInMillis());
    calTime.add(Calendar.MINUTE, 30);
    calendarIntent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, calTime.getTimeInMillis());
    calendarIntent.putExtra(Events.DESCRIPTION, description);
    startActivity(calendarIntent);//from   w  w w .  java 2  s .  c om
}

From source file:com.android.mms.ui.MessageUtils.java

public static void addNumberOrEmailtoContact(final String numberOrEmail, final int REQUEST_CODE,
        final Activity activity) {
    if (!TextUtils.isEmpty(numberOrEmail)) {
        String message = activity.getResources().getString(R.string.add_contact_dialog_message, numberOrEmail);
        AlertDialog.Builder builder = new AlertDialog.Builder(activity).setTitle(numberOrEmail)
                .setMessage(message);//from   w w  w.jav  a  2  s.co  m
        AlertDialog dialog = builder.create();
        dialog.setButton(AlertDialog.BUTTON_POSITIVE,
                activity.getResources().getString(R.string.add_contact_dialog_existing),
                new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        // TODO Auto-generated method stub
                        Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
                        intent.setType(Contacts.CONTENT_ITEM_TYPE);
                        if (Mms.isEmailAddress(numberOrEmail)) {
                            intent.putExtra(ContactsContract.Intents.Insert.EMAIL, numberOrEmail);
                        } else {
                            intent.putExtra(ContactsContract.Intents.Insert.PHONE, numberOrEmail);
                        }
                        if (REQUEST_CODE > 0) {
                            activity.startActivityForResult(intent, REQUEST_CODE);
                        } else {
                            activity.startActivity(intent);
                        }
                    }
                });

        dialog.setButton(AlertDialog.BUTTON_NEGATIVE,
                activity.getResources().getString(R.string.add_contact_dialog_new),
                new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        // TODO Auto-generated method stub
                        final Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
                        if (Mms.isEmailAddress(numberOrEmail)) {
                            intent.putExtra(ContactsContract.Intents.Insert.EMAIL, numberOrEmail);
                        } else {
                            intent.putExtra(ContactsContract.Intents.Insert.PHONE, numberOrEmail);
                        }
                        if (REQUEST_CODE > 0) {
                            activity.startActivityForResult(intent, REQUEST_CODE);
                        } else {
                            activity.startActivity(intent);
                        }
                    }
                });
        dialog.show();
    }
}