本文整理汇总了Java中android.content.Intent.ACTION_INSERT属性的典型用法代码示例。如果您正苦于以下问题:Java Intent.ACTION_INSERT属性的具体用法?Java Intent.ACTION_INSERT怎么用?Java Intent.ACTION_INSERT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.content.Intent
的用法示例。
在下文中一共展示了Intent.ACTION_INSERT属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareAddContactIntent
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;
}
示例2: addEventOnCalendar
@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);
}
示例3: openAddContact
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;
}
示例4: addCalendarEvent
/**
* 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
}
}
示例5: addCalendarEvent
/**
* 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
}
}