获取IllegalArgumentException尝试为android-calendar实现ExtendedProperties [英] Getting an IllegalArgumentException trying to implement ExtendedProperties for android-calendar
问题描述
我正在尝试为我的活动创建ExtendedProperties,并得到以下错误:
I am trying to create ExtendedProperties for my event and got this error below :
02-06 09:43:04.484: E/AndroidRuntime(9530): FATAL EXCEPTION: IntentService[AsyncQueryServiceHelper]
02-06 09:43:04.484: E/AndroidRuntime(9530): java.lang.IllegalArgumentException: Only sync adapters may write using content://com.android.calendar/extendedproperties
02-06 09:43:04.484: E/AndroidRuntime(9530): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:167)
02-06 09:43:04.484: E/AndroidRuntime(9530): at android.database.DatabaseUtils.readExceptionWithOperationApplicationExceptionFromParcel(DatabaseUtils.java:160)
02-06 09:43:04.484: E/AndroidRuntime(9530): at android.content.ContentProviderProxy.applyBatch(ContentProviderNative.java:484)
02-06 09:43:04.484: E/AndroidRuntime(9530): at android.content.ContentProviderClient.applyBatch(ContentProviderClient.java:227)
02-06 09:43:04.484: E/AndroidRuntime(9530): at android.content.ContentResolver.applyBatch(ContentResolver.java:954)
02-06 09:43:04.484: E/AndroidRuntime(9530): at com.android.calendar.iselection.AsyncQueryServiceHelper.onHandleIntent(AsyncQueryServiceHelper.java:327)
02-06 09:43:04.484: E/AndroidRuntime(9530): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
02-06 09:43:04.484: E/AndroidRuntime(9530): at android.os.Handler.dispatchMessage(Handler.java:99)
02-06 09:43:04.484: E/AndroidRuntime(9530): at android.os.Looper.loop(Looper.java:176)
02-06 09:43:04.484: E/AndroidRuntime(9530): at android.os.HandlerThread.run(HandlerThread.java:61)
我的代码如下:
ContentValues customerContentValues = new ContentValues();
Uri uriExtendedProperties = Uri.parse("content://com.android.calendar/extendedproperties");
customerContentValues.put(Events._ID,model.mId);
customerContentValues.put("ClientIdname", model.mCustomerName);
customerContentValues.put("RdvType", model.mEventType);
customerContentValues.put("RdvEmplacement", model.mEmplacement);
customerContentValues.put("RdvAdresse", model.mAddresse);
ops.add(ContentProviderOperation.newInsert(uriExtendedProperties).withValues(customerContentValues).build());
有没有什么我错过的?需要一些推...感谢提前
Is there anything i've missed ? need some push.. thanks in advance
有人告诉更多关于同步适配器的信号,我真的坚持....任何建议将受到欢迎。 p>
Is there somebody to tell more about sync adapter beacause i'm really stucked.... any suggestion will be welcomed.
推荐答案
ExtendedProperties
与普通 Evnets
和参加者
表。
为了写入它,您需要修改您正在使用的uri,并添加 caller_is_syncadapter , account_name 和 > account_type 'params。
in order to write to it you will need to modify the uri you are using and adding 'caller_is_syncadapter', 'account_name' and 'account_type' params.
这里是一个例子:
Uri extendedPropUri = ExtendedProperties.CONTENT_URI;
extendedPropUri = extendedPropUri.buildUpon()
.appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER,"true")
.appendQueryParameter(Calendars.ACCOUNT_NAME, this.accountName)
.appendQueryParameter(Calendars.ACCOUNT_TYPE, this.accountType).build();
然后插入如下:
ContentValues extraDataValues = new ContentValues();
extraDataValues.put(ExtendedProperties.EVENT_ID, eventId);
extraDataValues.put(ExtendedProperties.NAME, key);
extraDataValues.put(ExtendedProperties.VALUE, value);
context.getContentResolver().insert(extendedPropUri, extraDataValues);
这篇关于获取IllegalArgumentException尝试为android-calendar实现ExtendedProperties的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!