- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直在编写一个类来生成内容以在android设备上测试应用程序,但我一直遇到此错误。我对Java还是很陌生,所以我不太习惯解释这些运行时错误。任何帮助将不胜感激!我认为我的injectCalendar方法是造成这种情况的原因,但我不太确定...
import android.content.ContentProviderOperation;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.provider.CalendarContract;
import android.provider.UserDictionary;
import android.telephony.SmsManager;
import android.provider.ContactsContract.RawContacts;
import android.provider.Browser;
import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.CommonDataKinds.StructuredName;
import android.provider.ContactsContract.Contacts.Data;
import android.content.Intent;
import android.text.format.Time;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Locale;
import java.util.TimeZone;
class ContentInjector {
private Context mContext;
ContentInjector(Context context) { mContext = context; }
void injectSMS(String phone_number) {
String text_message = "hello world";
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phone_number, null, text_message, null, null);
}
void injectContact() {
ArrayList<ContentProviderOperation> op_list = new ArrayList<ContentProviderOperation>();
op_list.add(ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI)
.withValue(ContactsContract.RawContacts.ACCOUNT_TYPE, null)
.withValue(ContactsContract.RawContacts.ACCOUNT_NAME, null)
//.withValue(RawContacts.AGGREGATION_MODE, RawContacts.AGGREGATION_MODE_DEFAULT)
.build());
// first and last names
op_list.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
.withValueBackReference(Data.RAW_CONTACT_ID, 0)
.withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
.withValue(StructuredName.GIVEN_NAME, "Second Name")
.withValue(StructuredName.FAMILY_NAME, "First Name")
.build());
op_list.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
.withValueBackReference(Data.RAW_CONTACT_ID, 0)
.withValue(ContactsContract.Data.MIMETYPE,ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE)
.withValue(ContactsContract.CommonDataKinds.Phone.NUMBER, "09876543210")
.withValue(ContactsContract.CommonDataKinds.Phone.TYPE, Phone.TYPE_HOME)
.build());
op_list.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
.withValueBackReference(Data.RAW_CONTACT_ID, 0)
.withValue(ContactsContract.Data.MIMETYPE,ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE)
.withValue(ContactsContract.CommonDataKinds.Email.DATA, "abc@xyz.com")
.build());
try{
mContext.getContentResolver().applyBatch(ContactsContract.AUTHORITY, op_list);
}catch(Exception e){
e.printStackTrace();
}
}
void injectMMS(){}
void injectDict(){
UserDictionary.Words.addWord(mContext, "most frequently used word", 250, null, Locale.getDefault());
}
void injectCalendar() {
long startMillis = 0;
long endMillis = 0;
Calendar beginTime = Calendar.getInstance();
beginTime.set(2016, 9, 14, 7, 30);
startMillis = beginTime.getTimeInMillis();
Calendar endTime = Calendar.getInstance();
endTime.set(2016, 9, 14, 8, 45);
endMillis = endTime.getTimeInMillis();
String timeZone = TimeZone.getDefault().getID();
Uri calUri = CalendarContract.Calendars.CONTENT_URI;
ContentValues cv = new ContentValues();
cv.put(CalendarContract.Calendars.ACCOUNT_NAME, "CIFD ACCOUNT NAME");
cv.put(CalendarContract.Calendars.ACCOUNT_TYPE, CalendarContract.ACCOUNT_TYPE_LOCAL);
cv.put(CalendarContract.Calendars.NAME, "CIFD'S NAME");
cv.put(CalendarContract.Calendars.CALENDAR_DISPLAY_NAME, "CIFD CALENDAR DISPLAY NAME");
cv.put(CalendarContract.Calendars.OWNER_ACCOUNT, true);
cv.put(CalendarContract.Calendars.VISIBLE, 1);
cv.put(CalendarContract.Calendars.SYNC_EVENTS, 1);
cv.put(CalendarContract.Events.CALENDAR_ID, 1);
cv.put(CalendarContract.Events.DTSTART, startMillis);
cv.put(CalendarContract.Events.DTEND, endMillis);
cv.put(CalendarContract.Events.TITLE, "CIFD CALENDAR TITLE");
cv.put(CalendarContract.Events.DESCRIPTION, "CFID CALENDAR DESCRIPTION");
cv.put(CalendarContract.Events.EVENT_LOCATION, "CIFD CALENDAR LOCATION");
cv.put(CalendarContract.Events.ALL_DAY, 0); // 0 for false, 1 for true
cv.put(CalendarContract.Events.HAS_ALARM, 1); // 0 for false, 1 for true
cv.put(CalendarContract.Events.EVENT_TIMEZONE, timeZone);
calUri = calUri.buildUpon()
.appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true")
.appendQueryParameter(CalendarContract.Calendars.ACCOUNT_NAME, "CIFD ACCOUNT NAME")
.appendQueryParameter(CalendarContract.Calendars.ACCOUNT_TYPE, CalendarContract.ACCOUNT_TYPE_LOCAL)
.build();
mContext.getContentResolver().insert(calUri, cv);
}
private String getCalendarUriBase(Context context) {
String calendarUriBase = null;
Uri calendars = Uri.parse("content://calendar/calendars");
Cursor managedCursor = null;
try {
managedCursor = mContext.getContentResolver().query(calendars, null, null, null, null);
} catch (Exception e) {
}
if (managedCursor != null) {
calendarUriBase = "content://calendar/";
} else {
calendars = Uri.parse("content://com.android.calendar/calendars");
try {
managedCursor = mContext.getContentResolver().query(calendars, null, null, null, null);
} catch (Exception e) {
}
if (managedCursor != null) {
calendarUriBase = "content://com.android.calendar/";
}
}
return calendarUriBase;
}
void injectBookmark(){}
void injectSearch(){
}
}
11-25 21:05:34.589 16547-16547/com.mydata.contactlist I/LoadedApk: No resource references to update in package common
11-25 21:05:34.590 16547-16547/com.mydata.contactlist I/LoadedApk: No resource references to update in package com.cyngn.hexo
11-25 21:05:34.591 16547-16547/com.mydata.contactlist I/LoadedApk: No resource references to update in package com.cyngn.hexo
11-25 21:05:34.706 16547-16547/com.mydata.contactlist W/ResourceType: For resource 0x01030224, entry index(548) is beyond type entryCount(9)
11-25 21:05:34.706 16547-16547/com.mydata.contactlist W/ResourceType: For resource 0x01030224, entry index(548) is beyond type entryCount(9)
11-25 21:05:34.759 16547-16547/com.mydata.contactlist W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
11-25 21:05:34.852 16547-16566/com.mydata.contactlist D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
11-25 21:05:34.858 16547-16547/com.mydata.contactlist D/Atlas: Validating map...
11-25 21:05:34.888 16547-16566/com.mydata.contactlist I/Adreno-EGL: <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LA.BF.1.1.1_RB1.05.01.00.042.030_msm8974_LA.BF.1.1.1_RB1__release_AU ()
OpenGL ES Shader Compiler Version: E031.25.03.06
Build Date: 04/15/15 Wed
Local Branch: mybranch9068252
Remote Branch: quic/LA.BF.1.1.1_rb1.19
Local Patches: NONE
Reconstruct Branch: AU_LINUX_ANDROID_LA.BF.1.1.1_RB1.05.01.00.042.030 + NOTHING
11-25 21:05:34.888 16547-16566/com.mydata.contactlist I/OpenGLRenderer: Initialized EGL, version 1.4
11-25 21:05:34.903 16547-16566/com.mydata.contactlist D/OpenGLRenderer: Enabling debug mode 0
11-25 21:05:34.924 16547-16547/com.mydata.contactlist I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@2f9a9c54 time:6404104
11-25 21:05:36.807 16547-16547/com.mydata.contactlist I/Timeline: Timeline: Activity_launch_request id:com.mydata.contactlist time:6405987
11-25 21:05:37.172 16547-16547/com.mydata.contactlist I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@32dc9aac time:6406351
11-25 21:05:41.262 16547-16662/com.mydata.contactlist E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.mydata.contactlist, PID: 16547
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:304)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.IllegalArgumentException: column 'dtstart' is invalid
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:167)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
at android.content.ContentProviderProxy.insert(ContentProviderNative.java:476)
at android.content.ContentResolver.insert(ContentResolver.java:1207)
at com.mydata.contactlist.ContentInjector.injectCalendar(ContentInjector.java:123)
at com.mydata.contactlist.MainActivity$ExportThread.doInBackground(MainActivity.java:166)
at com.mydata.contactlist.MainActivity$ExportThread.doInBackground(MainActivity.java:158)
at android.os.AsyncTask$2.call(AsyncTask.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
最佳答案
应该是CalendarContract.EventsColumns.DTSTART
吗?尝试仅用CalendarContract.Events.DTSTART
替换"dtstart"
,然后看看会发生什么。
https://developer.android.com/reference/android/provider/CalendarContract.EventsColumns.html#DTSTART
关于java - CalendarContract:列“dtstart”无效(使用injectCalendar()),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40814340/
如何获取日历项的日期? dtStart 返回未知值,这不是我的事件条目日期。 eventUri = Uri.parse("content://com.android.calendar/event
在 iCalendar RFC 5545, section 3.3.10 ,看到如下UNTIL参数说明: The value of the UNTIL rule part MUST have the
实际上,我需要使用我的应用在 Google 日历中创建一个 Activity 。一切正常,我无法创建所需的开始时间和结束时间。任何人都可以帮我告诉我如何生成 dtstart 和 dtend。即我需要为
我有以下代码用于评论的丰富摘要: Author 1 Bla Bla Bla 2 days ago Aut
我尝试创建一个规则实例,然后设置开始日期/时间 (dtstart),但事件的时间错误。 我使用基础规则字符串初始化规则实例:RRULE:FREQ=WEEKLY;INTERVAL=1;WKST=MO;C
我一直在编写一个类来生成内容以在android设备上测试应用程序,但我一直遇到此错误。我对Java还是很陌生,所以我不太习惯解释这些运行时错误。任何帮助将不胜感激!我认为我的injectCalenda
有没有一种简单的方法可以使用 php 日期获取 iCal DTSTART 的正确格式? 如果我没有时间,我需要的格式如下:20111008T110000 或 20111008(这个很简单)。 PHP
在 angular js 服务文件中我使用 RRULE.WEEKLY 在这里我想给 dtStart 和 until 动态地处理多个事件 $scope.$watchGroup([
我需要根据重复事件计算下一个可能的日期。从 vcalender 我得到了这个信息: DTSTART;TZID=Europe/Berlin:20130711T130000 RRULE:FREQ=WEEK
我需要在我的 Android 应用程序中插入日历条目。现在我知道我不应该使用这种方法,但仍然如此。而且我确信我不是唯一的人...我在 stackoverflow 和互联网上进行了大量搜索,以了解我今天
我一直在尝试使用 python 的 dateutil rrule 来解析重复规则包裹 但是,我遇到了一个与我理解重复规则的方式不一致的奇怪错误 错误是 ValueError:当 DTSTART 是时区
我是一名优秀的程序员,十分优秀!