//calID 必传
long calID = 1;
long startMillis = 0;
long endMillis = 0;
//必传参数,开始时间
Calendar beginTime = Calendar.getInstance();
beginTime.set(2021,11,24,0,0);
startMillis = beginTime.getTimeInMillis();
//必传参数,结束时间
Calendar endTime = Calendar.getInstance();
endTime.set(2021,11,24,0,10);
//必传参数,时区
String timezone = TimeZone.getDefault().getID();
// Log.d(TAG,timezone);
ContentResolver contentResolver = getContentResolver();
ContentValues cv = new ContentValues();
cv.put(CalendarContract.Events.CALENDAR_ID,calID);
cv.put(CalendarContract.Events.DTSTART,startMillis);
cv.put(CalendarContract.Events.DTEND,endMillis);
cv.put(CalendarContract.Events.EVENT_TIMEZONE,timezone);
cv.put(CalendarContract.Events.TITLE,"这是圣诞测试哦");
cv.put(CalendarContract.Events.DESCRIPTION,"这是圣诞测试哦哦哦哦");
Uri uri = contentResolver.insert(CalendarContract.Events.CONTENT_URI,cv);
Log.d(TAG,"write success");
Log.d(TAG, String.valueOf(uri));
write success
content://com.android.calendar/events/9
但是日历里始终看不到写入的内容
使用 ContentResolver query 也看不到数据,是咋回事呢?
打印结果都一样,但就是读取不到数据
1
ImGroot 2021-12-23 13:10:26 +08:00
有没有申请权限?
|
2
chengyiqun 2021-12-23 14:11:21 +08:00
权限加了没
<uses-permission android:name="android.permission.READ_CALENDAR"/> <uses-permission android:name="android.permission.WRITE_CALENDAR"/> |
3
chengyiqun 2021-12-23 14:13:27 +08:00
至于访问外网, 宿主机上又 ssr 或者 v2y 的, 设置允许局域网访问, 然后到虚拟机里设置 wifi 的代理, 代理 ip 是宿主机的以太网或者 wlan 的 ip, 端口是代理软件的端口, 比如 ssr 默认 1080(可以修改)
|
4
Features OP @chengyiqun @ImGroot 加了,不加会闪退吧?
|