List of usage examples for android.content Intent ACTION_INSERT
String ACTION_INSERT
To view the source code for android.content Intent ACTION_INSERT.
Click Source Link
From source file:com.wit.android.support.content.intent.CalendarIntent.java
/** *//*from ww w . j a v a 2 s . c om*/ @Nullable @Override public Intent buildIntent() { switch (mType) { case TYPE_VIEW: if (checkTime(mBeginTime, "Time isn't valid.")) { final Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon(); builder.appendPath("time"); ContentUris.appendId(builder, mBeginTime); /** * Build the intent. */ return new Intent(Intent.ACTION_VIEW).setData(builder.build()); } break; case TYPE_INSERT_EVENT: if (!checkTime(mBeginTime, "Begin time(" + mBeginTime + ") isn't valid.")) { return null; } if (!checkTime(mEndTime, "End time(" + mEndTime + ") isn't valid.")) { return null; } if (mEndTime <= mBeginTime) { this.logMessage( "End time(" + mEndTime + ") is wrong specified before/at begin time(" + mBeginTime + ")."); return null; } /** * Build the intent. */ final Intent intent = new Intent(Intent.ACTION_INSERT).setData(CalendarContract.Events.CONTENT_URI) .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, mBeginTime) .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, mEndTime) .putExtra(CalendarContract.Events.TITLE, mTitle) .putExtra(CalendarContract.Events.DESCRIPTION, mDescription) .putExtra(CalendarContract.Events.EVENT_LOCATION, mLocation) .putExtra(CalendarContract.Events.AVAILABILITY, mAvailability); // todo: add extra emails. // intent.putExtra(Intent.EXTRA_EMAIL, "rowan@example.com,trevor@example.com"); return intent; case TYPE_EDIT_EVENT: if (checkEventId()) { /** * Build the intent. */ final Intent eventIntent = new Intent(Intent.ACTION_EDIT); eventIntent.setData(ContentUris.withAppendedId(CalendarContract.Events.CONTENT_URI, mEventId)); if (!TextUtils.isEmpty(mTitle)) { eventIntent.putExtra(CalendarContract.Events.TITLE, mTitle); } return eventIntent; } break; case TYPE_VIEW_EVENT: if (checkEventId()) { /** * Build the intent. */ return new Intent(Intent.ACTION_VIEW) .setData(ContentUris.withAppendedId(CalendarContract.Events.CONTENT_URI, mEventId)); } break; } return null; }
From source file:net.gsantner.opoc.util.ShareUtil.java
/** * Start calendar application to add new event, with given details prefilled *///from w w w .ja v a 2 s . c o m public boolean createCalendarAppointment(@Nullable String title, @Nullable String description, @Nullable String location, @Nullable Long... startAndEndTime) { Intent intent = new Intent(Intent.ACTION_INSERT).setData(CalendarContract.Events.CONTENT_URI); if (title != null) { intent.putExtra(CalendarContract.Events.TITLE, title); } if (description != null) { description = description.length() > 800 ? description.substring(0, 800) : description; intent.putExtra(CalendarContract.Events.DESCRIPTION, description); } if (location != null) { intent.putExtra(CalendarContract.Events.EVENT_LOCATION, location); } if (startAndEndTime != null) { if (startAndEndTime.length > 0 && startAndEndTime[0] > 0) { intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, startAndEndTime[0]); } if (startAndEndTime.length > 1 && startAndEndTime[1] > 0) { intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, startAndEndTime[1]); } } try { _context.startActivity(intent); return true; } catch (ActivityNotFoundException e) { return false; } }
From source file:edu.mit.mobile.android.livingpostcards.CardListFragment.java
private void createNewCard() { final Intent intent = new Intent(Intent.ACTION_INSERT, Card.CONTENT_URI); startActivity(intent); }
From source file:com.pgmacdesign.rsrtoolbox.FollowUp.java
public void CreateEvent() { //First run method that calculates all end times //Gets the current time in seconds Calendar mycal = Calendar.getInstance(); //secondsStart = c.get(Calendar.SECOND); GetEndTimes(); //Get the end times //Get Strings from EditTexts occ = follow_up_edit_text_occ_amount.getText().toString(); manager = follow_up_edit_text_manager.getText().toString(); customer_name = follow_up_edit_text_customer_name.getText().toString(); customer_number = follow_up_edit_text_customer_number.getText().toString(); notes = follow_up_edit_text_notes.getText().toString(); String superString = notes + "\nOCC: " + occ + "\nManager Involved: " + manager + "\nCustomer: " + customer_name + "\nCustomer Number: " + customer_number; //Create an intent that will enter data into the calendar Intent calIntent = new Intent(Intent.ACTION_INSERT); calIntent.setType("vnd.android.cursor.item/event"); //Put information in calIntent.putExtra(Events.TITLE, "Follow-up"); calIntent.putExtra(Events.EVENT_LOCATION, sp.getString(settings, "work_address", "Address")); calIntent.putExtra(Events.DESCRIPTION, superString); //Increment the date by X days mycal.add(mycal.DATE, duration);//from ww w .j a va 2 s. c om //Start and end time long startTime = mycal.getTimeInMillis(); //Convert to milliseconds long endTime = startTime + 900000; //15 minutes //Put the calculated start and end time into the calIntent Intent calIntent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, startTime); calIntent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime); //Puts event into calendar startActivity(calIntent); }
From source file:net.ddns.mlsoftlaberge.trycorder.contacts.ContactsListFragment.java
private void buttonadd() { final Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI); startActivity(intent); }
From source file:com.viktorrudometkin.burramys.activity.HomeActivity.java
public void onClickAdd(View view) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.menu_add_feed).setItems( new CharSequence[] { getString(R.string.add_custom_feed), getString(R.string.google_news_title) }, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (which == 0) { startActivity(new Intent(Intent.ACTION_INSERT).setData(FeedColumns.CONTENT_URI)); } else { startActivity(new Intent(HomeActivity.this, AddGoogleNewsActivity.class)); }/*w ww .j a va2s . c o m*/ } }); builder.show(); }
From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.list.ActivityList.java
public void addTaskInList(final String text, final long listId) { if (listId < 1) { // Cant add to invalid lists Snackbar.make(mFab, "Please create a list first", Snackbar.LENGTH_LONG).show(); return;//from w ww .j a v a2s . c om } final Intent intent = new Intent().setAction(Intent.ACTION_INSERT).setClass(this, ActivityEditor.class) .setData(Task.URI)//.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP) .putExtra(TaskDetailFragment.ARG_ITEM_LIST_ID, listId); // todo tablet /*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 startActivity(intent); //} }
From source file:inc.bait.jubilee.ui.fragments.ContactsListFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_add_contact: final Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI); startActivity(intent);// w w w . j ava 2 s.co m break; case R.id.menu_search: if (!ApiHelper.hasHoneycomb()) { getActivity().onSearchRequested(); } break; } return super.onOptionsItemSelected(item); }
From source file:at.jclehner.rxdroid.DrugListActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menuitem_date: { if (isShowingCurrentDate()) mDateClickListener.onLongClick(null); else// w ww. ja v a2 s . c o m mDateClickListener.onClick(null); return true; } case R.id.menuitem_patient: { } case R.id.menuitem_add: { Intent intent = new Intent(Intent.ACTION_INSERT); intent.setClass(this, DrugEditActivity.class); startActivity(intent); return true; } case R.id.menuitem_preferences: { Intent intent = new Intent(); intent.setClass(this, PreferencesActivity.class); startActivity(intent); return true; } case R.id.menuitem_toggle_filtering: { mShowingAll = !mShowingAll; invalidateViewPager(); return true; } case R.id.menuitem_take_all_pending: { final List<Drug> drugs = Entries.getAllDrugs(mCurrentPatientId); final DoseTimeInfo dtInfo = Settings.getDoseTimeInfo(); final int activeDoseTime = dtInfo.activeDoseTime(); final Date activeDate = dtInfo.activeDate(); int toastResId = R.string._toast_no_due_doses; int toastLength = Toast.LENGTH_SHORT; if (activeDoseTime != Schedule.TIME_INVALID) { int taken = 0, skipped = 0; for (Drug drug : drugs) { if (!drug.isActive()) continue; if (!Entries.findDoseEvents(drug, activeDate, activeDoseTime).isEmpty()) continue; final Fraction dose = drug.getDose(activeDoseTime, activeDate); if (!dose.isZero()) { final Fraction currentSupply = drug.getCurrentSupply(); if (!currentSupply.isZero()) { final Fraction newSupply = currentSupply.minus(dose); if (newSupply.isNegative()) { ++skipped; continue; } else { drug.setCurrentSupply(newSupply); Database.update(drug); } } Database.create(new DoseEvent(drug, activeDate, activeDoseTime, dose)); ++taken; } } if (skipped != 0) { toastResId = R.string._toast_some_due_doses_skipped; toastLength = Toast.LENGTH_LONG; } else if (taken != 0) toastResId = R.string._toast_all_due_doses_taken; } Toast.makeText(this, toastResId, toastLength).show(); } } return super.onOptionsItemSelected(item); }
From source file:fr.jcf.pret.activities.PretEmpruntActivity.java
/** * Cette mthode permet de grer les vnements lorsqu'un utilisateur slectionne une option de menu *///w w w. j a v a 2 s . co m @Override public boolean onMenuItemSelected(int featureId, MenuItem item) { switch (item.getItemId()) { case R.id.menu_creer_contact: // On affiche l'activity qui permet de crer un contact Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI); startActivity(intent); return true; default: return super.onOptionsItemSelected(item); } }