android.content.Intent#ACTION_INSERT源码实例Demo

下面列出了android.content.Intent#ACTION_INSERT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Linphone4Android   文件: 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);
	}
	
	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 项目: persian-calendar-view   文件: CalendarFragment.java
@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 项目: flutter_contacts   文件: ContactsServicePlugin.java
void openContactForm() {
  try {
    Intent intent = new Intent(Intent.ACTION_INSERT, ContactsContract.Contacts.CONTENT_URI);
    intent.putExtra("finishActivityOnSaveCompleted", true);
    startIntent(intent, REQUEST_OPEN_CONTACT_FORM);
  }catch(Exception e) {
  }
}
 
源代码4 项目: KUAS-AP-Material   文件: ScheduleFragment.java
public void AddCalendarEvent(String Msg) {
	String _time = Msg.split("\\) ")[0].substring(1);
	String _msg = Msg.split("\\) ")[1];
	String _startTime;
	String _endTime;
	if (_time.contains("~")) {
		_startTime = _time.split("~")[0].trim();
		_endTime = _time.split("~")[1].trim();
	} else {
		_startTime = _time;
		_endTime = _time;
	}
	Intent calendarIntent =
			new Intent(Intent.ACTION_INSERT, CalendarContract.Events.CONTENT_URI);
	Calendar beginTime = Calendar.getInstance();
	Calendar endTime = Calendar.getInstance();
	beginTime.set(Calendar.getInstance().get(Calendar.YEAR),
			Integer.parseInt(_startTime.split("/")[0]) - 1,
			Integer.parseInt(_startTime.split("/")[1]), 0, 0, 0);
	endTime.set(Calendar.getInstance().get(Calendar.YEAR),
			Integer.parseInt(_endTime.split("/")[0]) - 1,
			Integer.parseInt(_endTime.split("/")[1]), 23, 59, 59);
	calendarIntent
			.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, beginTime.getTimeInMillis());
	calendarIntent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime.getTimeInMillis());
	calendarIntent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, true);
	calendarIntent.putExtra(CalendarContract.Events.TITLE, _msg);
	calendarIntent.putExtra(CalendarContract.Events.EVENT_LOCATION, "國立高雄應用科技大學");
	try {
		startActivity(calendarIntent);
	} catch (ActivityNotFoundException e) {
		Toast.makeText(getContext(), R.string.calender_app_not_found, Toast.LENGTH_SHORT)
				.show();
	}
}
 
源代码5 项目: KUAS-AP-Material   文件: ScheduleFragment.java
public void AddCalendarEvent(String Msg) {
	String _time = Msg.split("\\) ")[0].substring(1);
	String _msg = Msg.split("\\) ")[1];
	String _startTime;
	String _endTime;
	if (_time.contains("~")) {
		_startTime = _time.split("~")[0].trim();
		_endTime = _time.split("~")[1].trim();
	} else {
		_startTime = _time;
		_endTime = _time;
	}
	Intent calendarIntent =
			new Intent(Intent.ACTION_INSERT, CalendarContract.Events.CONTENT_URI);
	Calendar beginTime = Calendar.getInstance();
	Calendar endTime = Calendar.getInstance();
	beginTime.set(Calendar.getInstance().get(Calendar.YEAR),
			Integer.parseInt(_startTime.split("/")[0]) - 1,
			Integer.parseInt(_startTime.split("/")[1]), 0, 0, 0);
	endTime.set(Calendar.getInstance().get(Calendar.YEAR),
			Integer.parseInt(_endTime.split("/")[0]) - 1,
			Integer.parseInt(_endTime.split("/")[1]), 23, 59, 59);
	calendarIntent
			.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, beginTime.getTimeInMillis());
	calendarIntent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime.getTimeInMillis());
	calendarIntent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, true);
	calendarIntent.putExtra(CalendarContract.Events.TITLE, _msg);
	calendarIntent.putExtra(CalendarContract.Events.EVENT_LOCATION, "國立高雄應用科技大學");
	startActivity(calendarIntent);
}
 
源代码6 项目: 365browser   文件: TabContextMenuItemDelegate.java
@Override
public void onAddToContacts(String url) {
    Intent intent = new Intent(Intent.ACTION_INSERT);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
    if (MailTo.isMailTo(url)) {
        intent.putExtra(
                ContactsContract.Intents.Insert.EMAIL, MailTo.parse(url).getTo().split(",")[0]);
    } else if (UrlUtilities.isTelScheme(url)) {
        intent.putExtra(ContactsContract.Intents.Insert.PHONE, UrlUtilities.getTelNumber(url));
    }
    IntentUtils.safeStartActivity(mTab.getActivity(), intent);
}
 
源代码7 项目: flow-android   文件: CalendarHelper.java
public static Intent getAddCalenderEventIntent(Exam exam) {
    String courseId = exam.getCourseId();
    String sections = exam.getSections();
    String location = exam.getLocation();
    String startDate = "";
    String endDate = "";
    String startTime = "";
    String endTime = "";

    Intent intent = new Intent(Intent.ACTION_INSERT);
    if (exam.getStartDate() != 0 && exam.getEndDate() != 0) {
        // Missing start/end date. Let's leave this to the user to enter
        startDate = getDateString(new Date(exam.getStartDate()));
        endDate = getDateString(new Date(exam.getEndDate()));
        startTime = getTimeString(new Date(exam.getStartDate()));
        endTime = getTimeString(new Date(exam.getEndDate()));

        // TODO: verify that the format of exam.getStartDate() is appropriate
        intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, exam.getStartDate())
                .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, exam.getEndDate());

    }
    intent.setData(CalendarContract.Events.CONTENT_URI)
            .putExtra(CalendarContract.Events.TITLE,
                    String.format("%s Exam", courseId.toUpperCase()))
            .putExtra(CalendarContract.Events.DESCRIPTION,
                    String.format("Course: %s\nSection: %s\nDate: %s\nTime: %s - %s\nLocation: %s",
                            courseId,
                            sections,
                            startDate,
                            startTime,
                            endTime,
                            location))
            .putExtra(CalendarContract.Events.EVENT_LOCATION, location)
            .putExtra(CalendarContract.Events.AVAILABILITY, CalendarContract.Events.AVAILABILITY_BUSY);
    return intent;
}
 
源代码8 项目: opentasks   文件: TaskListActivity.java
@Override
public void onAddNewTask()
{
    Intent editTaskIntent = new Intent(Intent.ACTION_INSERT);
    editTaskIntent.setData(Tasks.getContentUri(mAuthority));
    startActivityForResult(editTaskIntent, REQUEST_CODE_NEW_TASK);
}
 
源代码9 项目: opentasks   文件: QuickAddDialogFragment.java
/**
 * Launch the task editor activity.
 */
private void editTask()
{
    Intent intent = new Intent(Intent.ACTION_INSERT);
    intent.setData(Tasks.getContentUri(mAuthority));
    Bundle extraBundle = new Bundle();
    extraBundle.putParcelable(EditTaskActivity.EXTRA_DATA_CONTENT_SET, buildContentSet());
    intent.putExtra(EditTaskActivity.EXTRA_DATA_BUNDLE, extraBundle);
    getActivity().startActivity(intent);
}
 
源代码10 项目: codeexamples-android   文件: MyCalendarActivity.java
public void onClick(View view) {
	// Intent calIntent = new Intent(Intent.ACTION_INSERT);
	// calIntent.setData(CalendarContract.Events.CONTENT_URI);
	// startActivity(calIntent);

	Intent intent = new Intent(Intent.ACTION_INSERT);
	intent.setType("vnd.android.cursor.item/event");
	intent.putExtra(Events.TITLE, "Learn Android");
	intent.putExtra(Events.EVENT_LOCATION, "Home suit home");
	intent.putExtra(Events.DESCRIPTION, "Download Examples");

	// Setting dates
	GregorianCalendar calDate = new GregorianCalendar(2012, 10, 02);
	intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME,
			calDate.getTimeInMillis());
	intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME,
			calDate.getTimeInMillis());

	// Make it a full day event
	intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, true);

	// Make it a recurring Event
	intent.putExtra(Events.RRULE,
			"FREQ=WEEKLY;COUNT=11;WKST=SU;BYDAY=TU,TH");

	// Making it private and shown as busy
	intent.putExtra(Events.ACCESS_LEVEL, Events.ACCESS_PRIVATE);
	intent.putExtra(Events.AVAILABILITY, Events.AVAILABILITY_BUSY);

	startActivity(intent);

}
 
源代码11 项目: callerid-for-android   文件: NewContactsHelper.java
public Intent createContactEditor(CallerIDResult result) {
	final Intent intent = new Intent(Intent.ACTION_INSERT);
	intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
	intent.putExtra(ContactsContract.Intents.Insert.NAME, result.getName());
	intent.putExtra(ContactsContract.Intents.Insert.PHONE, result.getPhoneNumber());
	if(result.getAddress()!=null) intent.putExtra(ContactsContract.Intents.Insert.POSTAL, result.getAddress());
	return intent;
}
 
源代码12 项目: zxingfragmentlib   文件: CalendarResultHandler.java
/**
 * 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
  }
}
 
/**
 * 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
  }
}
 
/**
 * 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
  }
}
 
源代码15 项目: weex   文件: CalendarResultHandler.java
/**
 * 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
  }
}
 
源代码16 项目: Study_Android_Demo   文件: CalendarResultHandler.java
/**
 * 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
  }
}
 
/**
 * 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
  }
}
 
源代码18 项目: reacteu-app   文件: CalendarResultHandler.java
/**
 * 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
  }
}
 
源代码19 项目: 365browser   文件: TabContextMenuItemDelegate.java
@Override
public boolean supportsAddToContacts() {
    Intent intent = new Intent(Intent.ACTION_INSERT);
    intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
    return mTab.getWindowAndroid().canResolveActivity(intent);
}
 
源代码20 项目: opentasks   文件: TaskListWidgetProvider.java
@Override
public void onReceive(Context context, Intent intent)
{
    super.onReceive(context, intent);

    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
    int[] appWidgetIds = appWidgetManager.getAppWidgetIds(getComponentName(context));
    String action = intent.getAction();
    if (action.equals(Intent.ACTION_PROVIDER_CHANGED))
    {
        appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.task_list_widget_lv);
    }
    else if (action.equals(ACTION_CREATE_TASK))
    {
        int widgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, 0);
        WidgetConfigurationDatabaseHelper configHelper = new WidgetConfigurationDatabaseHelper(context);
        SQLiteDatabase db = configHelper.getReadableDatabase();
        ArrayList<Long> widgetLists = WidgetConfigurationDatabaseHelper.loadTaskLists(db, widgetId);
        db.close();
        ArrayList<Long> writableLists = new ArrayList<>();
        String authority = AuthorityUtil.taskAuthority(context);
        if (!widgetLists.isEmpty())
        {
            Cursor cursor = context.getContentResolver().query(
                    TaskLists.getContentUri(authority),
                    new String[] { TaskLists._ID },
                    TaskLists.SYNC_ENABLED + "=1 AND " + TaskLists._ID + " IN (" + TextUtils.join(",", widgetLists) + ")",
                    null,
                    null);
            if (cursor != null)
            {
                while (cursor.moveToNext())
                {
                    writableLists.add(cursor.getLong(0));
                }
                cursor.close();
            }
        }
        Intent editTaskIntent = new Intent(Intent.ACTION_INSERT);
        editTaskIntent.setData(Tasks.getContentUri(authority));
        editTaskIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        if (!writableLists.isEmpty())
        {
            Long preselectList;
            if (writableLists.size() == 1)
            {
                // if there is only one list, then select this one
                preselectList = writableLists.get(0);
            }
            else
            {
                // if there are multiple lists, then select the most recently used
                preselectList = RecentlyUsedLists.getRecentFromList(context, writableLists);
            }
            Log.d(getClass().getSimpleName(), "create task with preselected list " + preselectList);
            ContentSet contentSet = new ContentSet(Tasks.getContentUri(authority));
            contentSet.put(Tasks.LIST_ID, preselectList);
            Bundle extraBundle = new Bundle();
            extraBundle.putParcelable(EditTaskActivity.EXTRA_DATA_CONTENT_SET, contentSet);
            editTaskIntent.putExtra(EditTaskActivity.EXTRA_DATA_BUNDLE, extraBundle);
        }
        context.startActivity(editTaskIntent);
    }
}
 
 方法所在类
 同类方法