当前位置: 首页>>代码示例>>Java>>正文


Java Calendars.CONTENT_URI属性代码示例

本文整理汇总了Java中android.provider.CalendarContract.Calendars.CONTENT_URI属性的典型用法代码示例。如果您正苦于以下问题:Java Calendars.CONTENT_URI属性的具体用法?Java Calendars.CONTENT_URI怎么用?Java Calendars.CONTENT_URI使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.provider.CalendarContract.Calendars的用法示例。


在下文中一共展示了Calendars.CONTENT_URI属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCalendars

/**
 * Returns a list of calendars available on the phone
 * @param context
 * @return list of CalendarInstances
 */
public static ArrayList<CalendarInstance> getCalendars(Context context) {
	ArrayList<CalendarInstance> result = new ArrayList<CalendarInstance>();
	
	Cursor cur = null;
	ContentResolver cr = context.getContentResolver();
	Uri uri = Calendars.CONTENT_URI;   
	String selection = null;
	String[] selectionArgs = null; 
	cur = cr.query(uri, new String[]{Calendars._ID, Calendars.NAME, Calendars.CALENDAR_DISPLAY_NAME, Calendars.ACCOUNT_NAME}, selection, selectionArgs, null);
	
	while (cur.moveToNext()) {
		result.add(new CalendarInstance(cur.getLong(cur.getColumnIndex(Calendars._ID)), cur.getString(cur.getColumnIndex(Calendars.CALENDAR_DISPLAY_NAME)), cur.getString(cur.getColumnIndex(Calendars.ACCOUNT_NAME))));
	}
	
	cur.close();
	
	return result;
}
 
开发者ID:JanBobolz,项目名称:agendawatchfaceAndroid,代码行数:23,代码来源:AgendaCalendarService.java

示例2: listCalendars

/**
 * List the user's calendars
 *
 * @return All calendars of the user
 */
public Calendar[] listCalendars() {

	ContentResolver cr = context.getContentResolver();

	Uri calendarUri = Calendars.CONTENT_URI;

	Cursor cur
		= cr.query(calendarUri, CALENDAR_PROJECTION, null, null, null);

	if (cur == null)
		return null;

	Calendar[] res = new Calendar[cur.getCount()];

	int i = 0;
	while (cur.moveToNext())
	{

		long calendarId = cur.getLong(CALENDAR_PROJECTION_ID_INDEX);
		res[i] = new Calendar(calendarId,
					cur.getString(CALENDAR_PROJECTION_DISPLAY_NAME_INDEX),
					cur.getInt(CALENDAR_PROJECTION_IS_SYNCED_INDEX) == 1);

		i++;
	}
	cur.close();

	return res;
}
 
开发者ID:rparkins999,项目名称:CalendarTrigger,代码行数:34,代码来源:CalendarProvider.java

示例3: setSummaryCMSDP

@SuppressLint("MissingPermission")
private void setSummaryCMSDP()
{
    String prefVolumeDataSummary = _context.getString(R.string.calendars_multiselect_summary_text_not_selected);
    if (Permissions.checkCalendar(_context)) {
        if (!value.isEmpty()) {
            String[] splits = value.split("\\|");
            if (splits.length == 1) {
                boolean found = false;
                Cursor cur;
                ContentResolver cr = _context.getContentResolver();
                Uri uri = Calendars.CONTENT_URI;
                String selection = Calendars._ID + "=" + splits[0];
                //noinspection MissingPermission
                cur = cr.query(uri, CALENDAR_PROJECTION, selection, null, null);
                if (cur != null) {
                    //while (cur.moveToNext()) {
                    if (cur.moveToFirst()) {
                        found = true;
                        prefVolumeDataSummary = cur.getString(PROJECTION_DISPLAY_NAME_INDEX);
                        //break;
                    }
                    cur.close();
                }
                if (!found)
                    prefVolumeDataSummary = _context.getString(R.string.calendars_multiselect_summary_text_selected) + ": " + splits.length;
            } else
                prefVolumeDataSummary = _context.getString(R.string.calendars_multiselect_summary_text_selected) + ": " + splits.length;
        }
    }
    setSummary(prefVolumeDataSummary);
}
 
开发者ID:henrichg,项目名称:PhoneProfilesPlus,代码行数:32,代码来源:CalendarsMultiSelectDialogPreference.java

示例4: onCreateLoader

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    mArgs[0] = mAccount.name;
    mArgs[1] = mAccount.type;
    return new CursorLoader(
            getActivity(), Calendars.CONTENT_URI, PROJECTION, SELECTION, mArgs, SORT_ORDER);
}
 
开发者ID:x7hub,项目名称:Calendar_lunar,代码行数:7,代码来源:SelectCalendarsSyncFragment.java

示例5: getCalendarCrusor

private  static Cursor getCalendarCrusor(Context context)
	
	{
		String[] EVENT_PROJECTION = new String[] {
			    BaseColumns._ID,                           // 0
			    Calendars.ACCOUNT_NAME,                  // 1
			    Calendars.CALENDAR_DISPLAY_NAME,         // 2
			    Calendars.OWNER_ACCOUNT                  // 3
			};
//		String[] EVENT_PROJECTION = new String[] {
//				 "_id", "name" 
//			};
			// The indices for the projection array above.
		
		
		Cursor  cursor  = null;
		ContentResolver cr = context.getContentResolver();
		Uri uri = Calendars.CONTENT_URI;
		String selection = "((" + Calendars.ACCOUNT_NAME + " = ?) AND (" 
		                        + Calendars.ACCOUNT_TYPE + " = ?) AND ("
		                        + Calendars.OWNER_ACCOUNT + " = ?))";
		String[] selectionArgs = new String[] {"com.google"}; 
		// Submit the query and get a Cursor object back. 

		return cr.query(uri, EVENT_PROJECTION, null, null, null);
		
		
		
	}
 
开发者ID:marbergq,项目名称:Multiplanner,代码行数:29,代码来源:ShareModel.java

示例6: queryCalendar

public void queryCalendar(View view) {
	// Run query
	Cursor cur = null;
	ContentResolver cr = getContentResolver();
	Uri uri = Calendars.CONTENT_URI;
	String selection = "((" + Calendars.ACCOUNT_NAME + " = ?) AND ("
			+ Calendars.ACCOUNT_TYPE + " = ?))";

	// Replace this with your own user and account type
	String[] selectionArgs = new String[] { "[email protected]",
			"com.google" };
	// Submit the query and get a Cursor object back.
	cur = cr.query(uri, EVENT_PROJECTION, selection, selectionArgs, null);
	Toast.makeText(this, String.valueOf(cur.getCount()), Toast.LENGTH_LONG)
			.show();
	// Use the cursor to step through the returned records
	while (cur.moveToNext()) {
		long calID = 0;
		String displayName = null;
		String accountName = null;

		// Get the field values
		calID = cur.getLong(PROJECTION_ID_INDEX);
		displayName = cur.getString(PROJECTION_DISPLAY_NAME_INDEX);
		accountName = cur.getString(PROJECTION_ACCOUNT_NAME_INDEX);

		// Do something with the values...
		Toast.makeText(this, "Calendar " + displayName, Toast.LENGTH_SHORT)
				.show();
	}
}
 
开发者ID:vogellacompany,项目名称:codeexamples-android,代码行数:31,代码来源:MyCalendarActivity.java

示例7: listCalendars

/**
 * List the user's calendars
 * @return All calendars of the user, null if they could not be read
 */
public Calendar[] listCalendars(boolean forceRefresh) {
	
	if(savedCalendars != null && !forceRefresh)
		return savedCalendars;

       int permissionCheck = ContextCompat.checkSelfPermission(context, Manifest.permission.READ_CALENDAR);
       if(permissionCheck != PackageManager.PERMISSION_GRANTED) {
           return null;
       }
	
	Cursor cur;
	ContentResolver cr = context.getContentResolver();
	
	Uri calendarUri = Calendars.CONTENT_URI;
	
	cur = cr.query(calendarUri, CALENDAR_PROJECTION, null, null, null);
	
	if(cur == null) {
           return null;
       }
	
	LinkedHashMap<Long, Boolean> checkedCalendars = PreferencesManager.getCheckedCalendars(context);
	
	Calendar[] res = new Calendar[cur.getCount()];
	
	int i=0;
	while(cur.moveToNext()) {
		
		long calendarId = cur.getLong(CALENDAR_PROJECTION_ID_INDEX);
		res[i] = new Calendar(calendarId,
				cur.getString(CALENDAR_PROJECTION_DISPLAY_NAME_INDEX),
				cur.getInt(CALENDAR_PROJECTION_IS_SYNCED_INDEX) == 1,
				checkedCalendars.containsKey(calendarId) && checkedCalendars.get(calendarId)); // Calendar is checked
		
		i++;
	}
	cur.close();
	
	savedCalendars = res;
	
	return res;
}
 
开发者ID:RemiNV,项目名称:CalendarMute,代码行数:46,代码来源:CalendarProvider.java

示例8: getCalendarList

/**
 * get the List of the calendar
 * 
 * @return ArrayList with calendar names with account type
 *         Calendars.ACCOUNT_TYPE
 */
public ArrayList<String> getCalendarList(Context context) {
	ArrayList<String> calendarList = new ArrayList<String>();

	Uri uri = Calendars.CONTENT_URI;

	Cursor cur = null;

	ContentResolver cr = context.getContentResolver();

	cur = cr.query(uri, CALENDAR_PROJECTION, Calendars.ACCOUNT_TYPE + " = ?", new String[] { Constants.ACCOUNT_TYPE }, null);

	while (cur.moveToNext()) {
		String calendarName = null;

		calendarName = cur.getString(0);

		calendarList.add(calendarName);

		Log.d("CALENDAR_NAME", calendarName);
	}
	cur.close();
	return calendarList;

}
 
开发者ID:DHBWLoerrach,项目名称:campus-app,代码行数:30,代码来源:CalendarManager.java

示例9: getEventAccessLevel

private static int getEventAccessLevel(Context context, Event e) {
    ContentResolver cr = context.getContentResolver();

    int accessLevel = Calendars.CAL_ACCESS_NONE;

    // Get the calendar id for this event
    Cursor cursor = cr.query(ContentUris.withAppendedId(Events.CONTENT_URI, e.id),
            new String[] { Events.CALENDAR_ID },
            null /* selection */,
            null /* selectionArgs */,
            null /* sort */);

    if (cursor == null) {
        return ACCESS_LEVEL_NONE;
    }

    if (cursor.getCount() == 0) {
        cursor.close();
        return ACCESS_LEVEL_NONE;
    }

    cursor.moveToFirst();
    long calId = cursor.getLong(0);
    cursor.close();

    Uri uri = Calendars.CONTENT_URI;
    String where = String.format(CALENDARS_WHERE, calId);
    cursor = cr.query(uri, CALENDARS_PROJECTION, where, null, null);

    String calendarOwnerAccount = null;
    if (cursor != null) {
        cursor.moveToFirst();
        accessLevel = cursor.getInt(CALENDARS_INDEX_ACCESS_LEVEL);
        calendarOwnerAccount = cursor.getString(CALENDARS_INDEX_OWNER_ACCOUNT);
        cursor.close();
    }

    if (accessLevel < Calendars.CAL_ACCESS_CONTRIBUTOR) {
        return ACCESS_LEVEL_NONE;
    }

    if (e.guestsCanModify) {
        return ACCESS_LEVEL_EDIT;
    }

    if (!TextUtils.isEmpty(calendarOwnerAccount)
            && calendarOwnerAccount.equalsIgnoreCase(e.organizer)) {
        return ACCESS_LEVEL_EDIT;
    }

    return ACCESS_LEVEL_DELETE;
}
 
开发者ID:x7hub,项目名称:Calendar_lunar,代码行数:52,代码来源:DayView.java


注:本文中的android.provider.CalendarContract.Calendars.CONTENT_URI属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。