Java Code Examples for android.content.Intent.ACTION_INSERT

The following are Jave code examples for showing how to use ACTION_INSERT of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Linphone4Android   File: ApiElevenPlus.java   View Source Code Vote up 7 votes
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);
	}
	
	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;
}
 
Example 2
Project: persian-calendar-view   File: CalendarFragment.java   View Source Code Vote up 7 votes
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void addEventOnCalendar(PersianDate persianDate) {
    Intent intent = new Intent(Intent.ACTION_INSERT);
    intent.setData(CalendarContract.Events.CONTENT_URI);

    CivilDate civil = DateConverter.persianToCivil(persianDate);

    intent.putExtra(CalendarContract.Events.DESCRIPTION,
            mPersianCalendarHandler.dayTitleSummary(persianDate));

    Calendar time = Calendar.getInstance();
    time.set(civil.getYear(), civil.getMonth() - 1, civil.getDayOfMonth());

    intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME,
            time.getTimeInMillis());
    intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME,
            time.getTimeInMillis());
    intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, true);

    startActivity(intent);
}
 
Example 3
Project: MaterialAbout   File: IntentUtil.java   View Source Code Vote up 6 votes
public Intent openAddContact (String name, String phone) {
	Intent intent = new Intent(Intent.ACTION_INSERT);
	intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
	
	intent.putExtra(ContactsContract.Intents.Insert.NAME, name);
	intent.putExtra(ContactsContract.Intents.Insert.PHONE, phone);
	
	return intent;
}
 
Example 4
Project: keepass2android   File: CalendarResultHandler.java   View Source Code Vote up 5 votes
/**
 * Sends an intent to create a new calendar event by prepopulating the Add Event UI. Older
 * versions of the system have a bug where the event title will not be filled out.
 *
 * @param summary A description of the event
 * @param start   The start time
 * @param allDay  if true, event is considered to be all day starting from start time
 * @param end     The end time (optional)
 * @param location a text description of the event location
 * @param description a text description of the event itself
 * @param attendees attendees to invite
 */
private void addCalendarEvent(String summary,
                              Date start,
                              boolean allDay,
                              Date end,
                              String location,
                              String description,
                              String[] attendees) {
  Intent intent = new Intent(Intent.ACTION_INSERT);
  intent.setType("vnd.android.cursor.item/event");
  long startMilliseconds = start.getTime();
  intent.putExtra("beginTime", startMilliseconds);
  if (allDay) {
    intent.putExtra("allDay", true);
  }
  long endMilliseconds;
  if (end == null) {
    if (allDay) {
      // + 1 day
      endMilliseconds = startMilliseconds + 24 * 60 * 60 * 1000;
    } else {
      endMilliseconds = startMilliseconds;
    }
  } else {
    endMilliseconds = end.getTime();
  }
  intent.putExtra("endTime", endMilliseconds);
  intent.putExtra("title", summary);
  intent.putExtra("eventLocation", location);
  intent.putExtra("description", description);
  if (attendees != null) {
    intent.putExtra(Intent.EXTRA_EMAIL, attendees);
    // Documentation says this is either a String[] or comma-separated String, which is right?
  }

  try {
    // Do this manually at first
    rawLaunchIntent(intent);
  } catch (ActivityNotFoundException anfe) {
    Log.w(TAG, "No calendar app available that responds to " + Intent.ACTION_INSERT);
    // For calendar apps that don't like "INSERT":
    intent.setAction(Intent.ACTION_EDIT);
    launchIntent(intent); // Fail here for real if nothing can handle it
  }
}
 
Example 5
Project: weex-3d-map   File: CalendarResultHandler.java   View Source Code Vote up 5 votes
/**
 * Sends an intent to create a new calendar event by prepopulating the Add Event UI. Older
 * versions of the system have a bug where the event title will not be filled out.
 *
 * @param summary A description of the event
 * @param start   The start time
 * @param allDay  if true, event is considered to be all day starting from start time
 * @param end     The end time (optional)
 * @param location a text description of the event location
 * @param description a text description of the event itself
 * @param attendees attendees to invite
 */
private void addCalendarEvent(String summary,
                              Date start,
                              boolean allDay,
                              Date end,
                              String location,
                              String description,
                              String[] attendees) {
  Intent intent = new Intent(Intent.ACTION_INSERT);
  intent.setType("vnd.android.cursor.item/event");
  long startMilliseconds = start.getTime();
  intent.putExtra("beginTime", startMilliseconds);
  if (allDay) {
    intent.putExtra("allDay", true);
  }
  long endMilliseconds;
  if (end == null) {
    if (allDay) {
      // + 1 day
      endMilliseconds = startMilliseconds + 24 * 60 * 60 * 1000;
    } else {
      endMilliseconds = startMilliseconds;
    }
  } else {
    endMilliseconds = end.getTime();
  }
  intent.putExtra("endTime", endMilliseconds);
  intent.putExtra("title", summary);
  intent.putExtra("eventLocation", location);
  intent.putExtra("description", description);
  if (attendees != null) {
    intent.putExtra(Intent.EXTRA_EMAIL, attendees);
    // Documentation says this is either a String[] or comma-separated String, which is right?
  }

  try {
    // Do this manually at first
    rawLaunchIntent(intent);
  } catch (ActivityNotFoundException anfe) {
    Log.w(TAG, "No calendar app available that responds to " + Intent.ACTION_INSERT);
    // For calendar apps that don't like "INSERT":
    intent.setAction(Intent.ACTION_EDIT);
    launchIntent(intent); // Fail here for real if nothing can handle it
  }
}
 
Example 6
Project: ZXingAndroidExt   File: CalendarResultHandler.java   View Source Code Vote up 5 votes
/**
 * Sends an intent to create a new calendar event by prepopulating the Add Event UI. Older
 * versions of the system have a bug where the event title will not be filled out.
 *
 * @param summary     A description of the event
 * @param start       The start time
 * @param allDay      if true, event is considered to be all day starting from start time
 * @param end         The end time (optional; can be < 0 if not specified)
 * @param location    a text description of the event location
 * @param description a text description of the event itself
 * @param attendees   attendees to invite
 */
private void addCalendarEvent(String summary,
                              long start,
                              boolean allDay,
                              long end,
                              String location,
                              String description,
                              String[] attendees) {
    Intent intent = new Intent(Intent.ACTION_INSERT);
    intent.setType("vnd.android.cursor.item/event");
    intent.putExtra("beginTime", start);
    if (allDay) {
        intent.putExtra("allDay", true);
    }
    if (end < 0L) {
        if (allDay) {
            // + 1 day
            end = start + 24 * 60 * 60 * 1000;
        } else {
            end = start;
        }
    }
    intent.putExtra("endTime", end);
    intent.putExtra("title", summary);
    intent.putExtra("eventLocation", location);
    intent.putExtra("description", description);
    if (attendees != null) {
        intent.putExtra(Intent.EXTRA_EMAIL, attendees);
        // Documentation says this is either a String[] or comma-separated String, which is right?
    }

    try {
        // Do this manually at first
        rawLaunchIntent(intent);
    } catch (ActivityNotFoundException anfe) {
        Log.w(TAG, "No calendar app available that responds to " + Intent.ACTION_INSERT);
        // For calendar apps that don't like "INSERT":
        intent.setAction(Intent.ACTION_EDIT);
        launchIntent(intent); // Fail here for real if nothing can handle it
    }
}
 
Example 7
Project: tvConnect_android   File: CalendarResultHandler.java   View Source Code Vote up 5 votes
/**
 * Sends an intent to create a new calendar event by prepopulating the Add Event UI. Older
 * versions of the system have a bug where the event title will not be filled out.
 *
 * @param summary A description of the event
 * @param start   The start time
 * @param allDay  if true, event is considered to be all day starting from start time
 * @param end     The end time (optional)
 * @param location a text description of the event location
 * @param description a text description of the event itself
 * @param attendees attendees to invite
 */
private void addCalendarEvent(String summary,
                              Date start,
                              boolean allDay,
                              Date end,
                              String location,
                              String description,
                              String[] attendees) {
  Intent intent = new Intent(Intent.ACTION_INSERT);
  intent.setType("vnd.android.cursor.item/event");
  long startMilliseconds = start.getTime();
  intent.putExtra("beginTime", startMilliseconds);
  if (allDay) {
    intent.putExtra("allDay", true);
  }
  long endMilliseconds;
  if (end == null) {
    if (allDay) {
      // + 1 day
      endMilliseconds = startMilliseconds + 24 * 60 * 60 * 1000;
    } else {
      endMilliseconds = startMilliseconds;
    }
  } else {
    endMilliseconds = end.getTime();
  }
  intent.putExtra("endTime", endMilliseconds);
  intent.putExtra("title", summary);
  intent.putExtra("eventLocation", location);
  intent.putExtra("description", description);
  if (attendees != null) {
    intent.putExtra(Intent.EXTRA_EMAIL, attendees);
    // Documentation says this is either a String[] or comma-separated String, which is right?
  }

  try {
    // Do this manually at first
    rawLaunchIntent(intent);
  } catch (ActivityNotFoundException anfe) {
    Log.w(TAG, "No calendar app available that responds to " + Intent.ACTION_INSERT);
    // For calendar apps that don't like "INSERT":
    intent.setAction(Intent.ACTION_EDIT);
    launchIntent(intent); // Fail here for real if nothing can handle it
  }
}
 
Example 8
Project: tvConnect_android   File: CalendarResultHandler.java   View Source Code Vote up 5 votes
/**
 * Sends an intent to create a new calendar event by prepopulating the Add Event UI. Older
 * versions of the system have a bug where the event title will not be filled out.
 *
 * @param summary A description of the event
 * @param start   The start time
 * @param allDay  if true, event is considered to be all day starting from start time
 * @param end     The end time (optional)
 * @param location a text description of the event location
 * @param description a text description of the event itself
 * @param attendees attendees to invite
 */
private void addCalendarEvent(String summary,
                              Date start,
                              boolean allDay,
                              Date end,
                              String location,
                              String description,
                              String[] attendees) {
  Intent intent = new Intent(Intent.ACTION_INSERT);
  intent.setType("vnd.android.cursor.item/event");
  long startMilliseconds = start.getTime();
  intent.putExtra("beginTime", startMilliseconds);
  if (allDay) {
    intent.putExtra("allDay", true);
  }
  long endMilliseconds;
  if (end == null) {
    if (allDay) {
      // + 1 day
      endMilliseconds = startMilliseconds + 24 * 60 * 60 * 1000;
    } else {
      endMilliseconds = startMilliseconds;
    }
  } else {
    endMilliseconds = end.getTime();
  }
  intent.putExtra("endTime", endMilliseconds);
  intent.putExtra("title", summary);
  intent.putExtra("eventLocation", location);
  intent.putExtra("description", description);
  if (attendees != null) {
    intent.putExtra(Intent.EXTRA_EMAIL, attendees);
    // Documentation says this is either a String[] or comma-separated String, which is right?
  }

  try {
    // Do this manually at first
    rawLaunchIntent(intent);
  } catch (ActivityNotFoundException anfe) {
    Log.w(TAG, "No calendar app available that responds to " + Intent.ACTION_INSERT);
    // For calendar apps that don't like "INSERT":
    intent.setAction(Intent.ACTION_EDIT);
    launchIntent(intent); // Fail here for real if nothing can handle it
  }
}