0
工作我想在我的Android平板電腦3.2日曆事件不是在Android 3.2的平板電腦
int[] calIds = null;
Cursor cursor = getContentResolver()
.query(
Uri
.parse("content://com.android.calendar/calendars"),
new String[] { "_id",
"displayName" },
"selected=1", null, null);
if (cursor != null && cursor.moveToFirst()) {
String[] calNames = new String[cursor
.getCount()];
calIds = new int[cursor.getCount()];
for (int i = 0; i < calNames.length; i++) {
// retrieve the calendar names and
// ids
// at this stage you can print out
// the display names to get an idea
// of what calendars the user has
calIds[i] = cursor.getInt(0);
calNames[i] = cursor.getString(1);
cursor.moveToNext();
}
cursor.close();
if (calIds.length > 0) {
// we're safe here to do any further
// work
}
}
// grab calendar id from above
int cal_id = calIds[1];
// set the content value
ContentValues cv = new ContentValues();
// make sure you add it to the right
// calendar
cv.put("calendar_id", cal_id);
// set the title of the event
cv.put("title", Name.getText().toString());
// set the description of the event
cv.put("description", Address.getText()
.toString()
+ " ph:"
+ Phone.getText().toString());
// set the event's physical location
// cv.put("eventLocation",);
// set the start and end time
// note: you're going to need to convert the
// desired date into milliseconds
Calendar d = Calendar.getInstance();
d.set(2011, 10, 10, 3, 0, 0);
Calendar end = Calendar.getInstance();
end.set(2011, 10, 10, 9, 0, 0);
long startTime = d.getTimeInMillis();
long endTime = end.getTimeInMillis();
endTime = endTime * 1000;
startTime = startTime * 1000;
System.out.println("HOW TO SOL:VCE THIS");
System.out.println(startTime);
System.out.println(endTime);
cv.put("dtstart", startTime);
cv.put("dtend", endTime);
cv.put("rrule",
"FREQ=DAILY;BYDAY=MO,TU,WE,TH,FR"); // let
// the
// calendar
// know
// whether
// this
// event
// goes
// on
// all
// day
// or
// not
// true = 1, false = 0
// let the calendar know whether an alarm
// should go off for this event
// once desired fields are set, insert it
// into the table
getContentResolver()
.insert(
Uri
.parse("content://com.android.calendar/events"),
cv);
添加使用下面的代碼,日曆事件,但我無法插入事件。
在日誌中我得到以下
10-11 12:51:47.250: INFO/CalendarProvider2(24267): Sending notification intent: Intent { act=android.intent.action.PROVIDER_CHANGED dat=content://com.android.calendar }
10-11 12:51:47.250: WARN/ContentResolver(24267): Failed to get type for: content://com.android.calendar (Unknown URL content://com.android.calendar)
我應該如何解決這個問題的任何幫助.. 在此先感謝..
您正在使用的技術是無證,不支持的,並沒有任何擔保,以在任何給定的工作設備或操作系統版本。 – CommonsWare