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:org.dmfs.tasks.model.Model.java

public void startInsertIntent(Activity activity, Account account) {
    if (!hasInsertActivity()) {
        throw new IllegalStateException(
                "Syncadapter for " + mAccountType + " does not support inserting lists.");
    }//from  w  w  w  .  j av  a 2  s  . c  o  m

    activity.startActivity(getListIntent(mContext, Intent.ACTION_INSERT, account));
}

From source file:com.money.manager.ex.assetallocation.AssetClassEditActivity.java

private void loadIntent() {
    Intent intent = getIntent();//from   www  .j  av a  2s.  c o m
    if (intent == null)
        return;

    // Insert or Edit?
    mAction = intent.getAction();
    if (mAction == null)
        return;

    AssetClass assetClass = null;

    switch (mAction) {
    case Intent.ACTION_INSERT:
        assetClass = AssetClass.create("");
        int parentId = intent.getIntExtra(KEY_PARENT_ID, Constants.NOT_SET);
        assetClass.setParentId(parentId);
        break;

    case Intent.ACTION_EDIT:
        int id = intent.getIntExtra(Intent.EXTRA_UID, Constants.NOT_SET);
        this.assetClassId = id;

        // load class
        AssetClassRepository repo = new AssetClassRepository(this);
        assetClass = repo.load(id);
        if (assetClass == null) {
            new UIHelper(this).showToast("No asset class found in the database!");
            // todo: show error message and return (close edit activity)
            return;
        }
        break;
    }

    AssetClassEditFragment fragment = getFragment();
    fragment.assetClass = assetClass;
}

From source file:com.intuitlabs.wear.voiceandchoice.ActionReceiver.java

/**
 * {@inheritDoc}/*from  w w  w . j  a v  a 2s  .c o  m*/
 */
@Override
public void onReceive(final Context context, final Intent _intent) {

    /** notificationId used to issue the notification, so we can cancel the notification */
    final int notificationId = _intent.getIntExtra(Intent.EXTRA_UID, -1);

    /** The bundle that was created during the speech recognition process */
    final Bundle remoteInput = RemoteInput.getResultsFromIntent(_intent);

    /* The user's choice, either directly selected or as a speech recognition result. */
    final String reply = remoteInput != null
            ? remoteInput.getCharSequence(AndroidNotification.EXTRA_VOICE_REPLY).toString()
            : "";

    /* The integer value, associated with the command string in the original json document that was used to generate the notification */
    @SuppressWarnings("unchecked")
    final Map<String, Integer> cmdkeys = (Map<String, Integer>) ListStyle.readFromSharedPreference(context);
    final int selectedId = new PhoneticSearch<>(cmdkeys).match(reply);

    Log.v(LOG_TAG, "Selection / Speech Recognition result: " + reply);
    Log.i(LOG_TAG, "Selection / Selected ID " + selectedId);

    /* Cancel the Notification, which makes it disappear on phone and watch */
    final NotificationManager manager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    manager.cancel(notificationId);

    switch (selectedId) {
    // Purchase Turbo Tax / Go to Web Page
    case 0:
    case 4:
        final String url = context.getString(R.string.turbotax_url);
        context.startActivity(
                new Intent(Intent.ACTION_VIEW).setData(Uri.parse(url)).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
        break;

    // create a calendar Event
    case 1:
    case 5:
        final Calendar cal = Calendar.getInstance();
        cal.set(2015, 3, 15);

        final Intent intent = new Intent(Intent.ACTION_INSERT).setData(CalendarContract.Events.CONTENT_URI)
                .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, cal.getTimeInMillis())
                .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, cal.getTimeInMillis() + 60 * 60 * 1000)
                .putExtra(CalendarContract.Events.TITLE, context.getString(R.string.turbotax_title))
                .putExtra(CalendarContract.Events.DESCRIPTION, context.getString(R.string.turbotax_description))
                .putExtra(CalendarContract.Events.EVENT_LOCATION, context.getString(R.string.turbotax_location))
                .putExtra(CalendarContract.Events.AVAILABILITY, CalendarContract.Events.AVAILABILITY_BUSY)
                .putExtra(Intent.EXTRA_EMAIL, context.getString(R.string.turbotax_email))
                .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
        break;

    // set a reminder
    case 2:
    case 6:
        // todo, set a reminder ..
        break;

    // dismiss, do nothing
    case 3:
    case 7:
    default:
    }
}

From source file:org.linphone.compatibility.ApiElevenPlus.java

public static Intent prepareAddContactIntent(String displayName, String sipUri) {
    Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
    intent.putExtra(Insert.NAME, displayName);

    if (sipUri != null && sipUri.startsWith("sip:")) {
        sipUri = sipUri.substring(4);/* w  ww. j av a2s  . c om*/
    }

    ArrayList<ContentValues> data = new ArrayList<ContentValues>();
    ContentValues sipAddressRow = new ContentValues();
    sipAddressRow.put(Contacts.Data.MIMETYPE, SipAddress.CONTENT_ITEM_TYPE);
    sipAddressRow.put(SipAddress.SIP_ADDRESS, sipUri);
    data.add(sipAddressRow);
    intent.putParcelableArrayListExtra(Insert.DATA, data);

    return intent;
}

From source file:org.hfoss.posit.android.api.fragment.ListFindsFragment.java

/**
 * Starts FindActivty or replaces second side in pane with FindFragment
 * for find creation.//from ww w .ja  v  a2s. c o  m
 */
private void addFind() {
    if (mIsDualPane) {
        FindFragment findFragment = null;
        try {
            findFragment = (FindPluginManager.mFindPlugin.getmFindFragmentClass()).newInstance();
        } catch (java.lang.InstantiationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        if (findFragment == null) {
            Toast.makeText(getActivity(), "can't create find fragment", Toast.LENGTH_LONG).show();
            return;
        }

        Bundle extras = new Bundle();
        extras.putString("ACTION", Intent.ACTION_INSERT);

        findFragment.setArguments(extras);

        FragmentTransaction ft = getFragmentManager().beginTransaction();
        ft.replace(R.id.find, findFragment);
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        ft.commit();
    } else {
        Intent intent = new Intent(getActivity(), FindPluginManager.mFindPlugin.getmFindActivityClass());
        intent.setAction(Intent.ACTION_INSERT);
        startActivity(intent);
    }
}

From source file:com.dgsd.android.ShiftTracker.EditShiftActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.delete) {
        if (mEditShiftFragment.isEditing()) {
            //Remove any alarms
            AlarmUtils.get(this).cancel(mEditShiftFragment.getShift());
            DbService.async_delete(this, Provider.SHIFTS_URI,
                    DbField.ID + "=" + mEditShiftFragment.getEditingId());
        }//w w  w.  j a  va2s  .c om

        finish();
        return true;
    } else if (item.getItemId() == R.id.export_to_calendar) {
        final Shift shift = mEditShiftFragment == null ? null : mEditShiftFragment.getShift();
        if (!Api.isMin(Api.ICS) || shift == null)
            return true;

        Intent intent = new Intent(Intent.ACTION_INSERT);
        intent.setData(Events.CONTENT_URI);
        intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, shift.getStartTime());
        intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, shift.getEndTime());
        intent.putExtra(Events.TITLE, shift.name);
        intent.putExtra(Events.DESCRIPTION, shift.note);
        intent.putExtra(Events.AVAILABILITY, Events.AVAILABILITY_BUSY);

        startActivity(intent);

        return true;
    } else {
        return super.onOptionsItemSelected(item);
    }
}

From source file:at.jclehner.rxdroid.DrugEditFragment.java

public void onBackPressed() {
    final Intent intent = getActivity().getIntent();
    final String action = intent.getAction();

    final Drug drug = mWrapper.get();
    final String drugName = drug.getName();

    if (drugName == null || drugName.length() == 0) {
        showDrugDiscardDialog();/*from   w  w  w .  j  a v a  2s . c o  m*/
        return;
    }

    if (Intent.ACTION_EDIT.equals(action)) {
        if (mDrugHash != drug.hashCode()) {
            if (LOGV)
                Util.dumpObjectMembers(TAG, Log.VERBOSE, drug, "drug 2");

            showSaveChangesDialog();
            return;
        }
    } else if (Intent.ACTION_INSERT.equals(action)) {
        Database.create(drug, 0);
        Toast.makeText(getActivity(), getString(R.string._toast_saved), Toast.LENGTH_SHORT).show();
    }

    getActivity().finish();
}

From source file:spit.matrix2017.Fragments.ContactUsFragment.java

@Nullable
@Override//from   w w w  .j  ava  2s.c  o m
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_contactus, container, false);

    findOnMap = (Button) view.findViewById(R.id.findOnMap);
    visitWebsite = (Button) view.findViewById(R.id.visitWebsite);
    contact_one_Button = (AppCompatImageButton) view.findViewById(R.id.contact_us_call_one);
    contact_two_Button = (AppCompatImageButton) view.findViewById(R.id.contact_us_call_two);
    save_one_Button = (AppCompatImageButton) view.findViewById(R.id.contact_us_save_one);
    save_two_Button = (AppCompatImageButton) view.findViewById(R.id.contact_us_save_two);
    emailId_matrix_TextView = (TextView) view.findViewById(R.id.emailId_matrix_TextView);

    emailId_matrix_TextView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String to = "principal@spit.ac.in";
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_SENDTO);
            intent.setType("text/plain");
            intent.setData(Uri.parse("mailto:" + to));
            intent.putExtra(Intent.EXTRA_EMAIL, to);
            try {
                startActivity(Intent.createChooser(intent, "Send Email"));
            } catch (Exception e) {
                Toast.makeText(getActivity(), e.getStackTrace().toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });

    visitWebsite.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.spit.ac.in")));
        }
    });

    findOnMap.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Uri uri = Uri
                    .parse("http://maps.google.com/maps?q=" + Uri.encode(getString(R.string.college_name)));
            Intent mapIntent = new Intent(Intent.ACTION_VIEW, uri);
            mapIntent.setPackage("com.google.android.apps.maps");
            try {
                startActivity(mapIntent);
            } catch (ActivityNotFoundException ex) {
                try {
                    Intent newIntent = new Intent(Intent.ACTION_VIEW, uri);
                    startActivity(newIntent);
                } catch (ActivityNotFoundException innerEx) {
                    Toast.makeText(getContext(), "Please install a maps application", Toast.LENGTH_LONG).show();
                }
            }
        }
    });

    View.OnClickListener dialerOnClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_DIAL);
            switch (v.getId()) {
            case R.id.contact_us_call_one:
                intent.setData(Uri.parse("tel:" + "02226707440"));
                break;
            case R.id.contact_us_call_two:
                intent.setData(Uri.parse("tel:" + "02226287250"));
                break;
            }
            startActivity(intent);
        }
    };
    contact_one_Button.setOnClickListener(dialerOnClickListener);
    contact_two_Button.setOnClickListener(dialerOnClickListener);

    View.OnClickListener saveOnClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_INSERT, ContactsContract.Contacts.CONTENT_URI);
            switch (v.getId()) {
            case R.id.contact_us_save_one:
                intent.putExtra(ContactsContract.Intents.Insert.NAME, "S.P.I.T.");
                intent.putExtra(ContactsContract.Intents.Insert.PHONE, "02226707440");
                break;
            case R.id.contact_us_save_two:
                intent.putExtra(ContactsContract.Intents.Insert.NAME, "S.P.I.T.");
                intent.putExtra(ContactsContract.Intents.Insert.PHONE, "02226708520");
                break;
            }
            startActivity(intent);
        }
    };
    save_one_Button.setOnClickListener(saveOnClickListener);
    save_two_Button.setOnClickListener(saveOnClickListener);

    return view;
}

From source file:org.andstatus.app.account.AccountSettingsActivity.java

protected boolean selectOrigin() {
    Intent i = new Intent(AccountSettingsActivity.this, PersistentOriginList.class);
    i.setAction(Intent.ACTION_INSERT);
    startActivityForResult(i, ActivityRequestCode.SELECT_ORIGIN.id);
    return true;/*from w  w  w  .j a v  a2s . co m*/
}

From source file:pl.selvin.android.listsyncsample.ui.EditItemActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    try {/*  w w  w  . jav  a 2s .c om*/
        UserID = SyncHelper.createInstance(this).getUserId();
    } catch (Exception ex) {
        Toast.makeText(this, ex.getMessage(), Toast.LENGTH_LONG).show();
        finish();
    }
    setContentView(R.layout.edit_item_activity);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    edName = (EditText) findViewById(R.id.edName);
    edDesc = (EditText) findViewById(R.id.edDesc);
    sPriority = (Spinner) findViewById(R.id.sPriority);
    sStatus = (Spinner) findViewById(R.id.sStatus);
    tStartDate = (TextView) findViewById(R.id.tStartDate);
    tStartTime = (TextView) findViewById(R.id.tStartTime);
    tEndDate = (TextView) findViewById(R.id.tEndDate);
    tEndTime = (TextView) findViewById(R.id.tEndTime);
    tStartDate.setOnClickListener(this);
    tStartTime.setOnClickListener(this);
    tEndDate.setOnClickListener(this);
    tEndTime.setOnClickListener(this);
    adPriority = new SimpleCursorAdapter(this, R.layout.support_simple_spinner_dropdown_item, null,
            new String[] { Database.Priority.C_NAME }, new int[] { android.R.id.text1 }, 0);
    adPriority.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    sPriority.setAdapter(adPriority);
    adStatus = new SimpleCursorAdapter(this, R.layout.support_simple_spinner_dropdown_item, null,
            new String[] { Database.Status.NAME }, new int[] { android.R.id.text1 }, 0);
    adStatus.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    sStatus.setAdapter(adStatus);
    Intent intent = getIntent();
    if (!Intent.ACTION_INSERT.endsWith(intent.getAction())) {
        id = intent.getData();
    } else {
        listID = intent.getStringExtra(Item.LISTID);
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        tStartDate.setTag(cal);
        tStartDate.setText(sdfdate.format(cal.getTime()));
        tStartTime.setTag(cal);
        tStartTime.setText(sdftime.format(cal.getTime()));
        cal = Calendar.getInstance();
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        cal.add(Calendar.DAY_OF_MONTH, 1);
        tEndDate.setTag(cal);
        tEndDate.setText(sdfdate.format(cal.getTime()));
        tEndTime.setTag(cal);
        tEndTime.setText(sdftime.format(cal.getTime()));
    }

    final DatePickerFragment dateFragment = (DatePickerFragment) getSupportFragmentManager()
            .findFragmentByTag(DatePickerFragmentTag);
    if (dateFragment != null) {
        dateFragment.setOnDateSetListener(dpdfListener);
    }
    final TimePickerFragment timeFragment = (TimePickerFragment) getSupportFragmentManager()
            .findFragmentByTag(TimePickerFragmentTag);
    if (timeFragment != null) {
        timeFragment.setOnTimeSetListener(tpdfListener);
    }
    getSupportLoaderManager().initLoader(PriorityLoaderId, null, this);
}