android 日历
Android 日历
2023-09-11 14:14:59 时间
[1].[代码] [Java]代码 跳至 [1]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
//读取日历事件
public static
void getCalendarInfo(Activity activity,String tag){
String[] projection =
new String[]{CalendarContract.Events._ID,CalendarContract.Events.TITLE};
ContentResolver cr = activity.getContentResolver();
Cursor cursor = cr.query(CalendarContract.Events.CONTENT_URI, projection,
null , null ,
null ); int
idIndex = cursor.getColumnIndexOrThrow(CalendarContract.Events._ID);
Log.d(tag, cursor.getCount()+ "" );
int
titleIndex = cursor.getColumnIndexOrThrow(CalendarContract.Events.TITLE);
while
(cursor.moveToNext()) {
String id = cursor.getString(idIndex);
String title = cursor.getString(titleIndex);
Log.d(tag, id+ ":" +title);
}
cursor.close(); }
//插入事件
public static
void addCalendarEvent(Activity activity,String tag){
Intent intent = new
Intent(Intent.ACTION_INSERT,CalendarContract.Events.CONTENT_URI);
Log.d(tag, CalendarContract.Events.CONTENT_URI.toString());
intent.putExtra(CalendarContract.Events.TITLE, "Launch" );
intent.putExtra(CalendarContract.Events.DESCRIPTION,
"Launch,Android app" );
intent.putExtra(CalendarContract.Events.EVENT_LOCATION,
"baidu.com" );
Calendar calendar = Calendar.getInstance();
calendar.setTime( new
Date());
intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, calendar.getTimeInMillis());
intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY,
true );
activity.startActivity(intent); }
//编辑日历事件
public static
void editCalendarEvent(Activity activity,String tag){
long rowId = 1 ;
Uri editUri = ContentUris.withAppendedId(CalendarContract.Events.CONTENT_URI,rowId);
Log.d(tag, CalendarContract.Events.CONTENT_URI.toString());
Intent intent = new
Intent(Intent.ACTION_EDIT,editUri);
intent.putExtra(CalendarContract.Events.EVENT_LOCATION,
"NJ" );
Calendar calendar = Calendar.getInstance();
calendar.set( 2015 ,
2 , 17 ,
12 , 1 ,
1 );
intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, calendar.getTimeInMillis());
intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY,
true );
activity.startActivity(intent); }
//查看日历
public static
void viewCalendar(Activity activity,String tag){
Calendar calendar = Calendar.getInstance();
calendar.set( 2015 ,
2 , 17 ,
12 , 1 ,
1 );
Uri uri = Uri.parse( "content://com.android.calendar/time/" +calendar.getTimeInMillis());
Intent intent = new
Intent(Intent.ACTION_VIEW,uri);
activity.startActivity(intent); } |
相关文章
- [Android Pro] android root权限破解分析
- 【黑马Android】(02)短信发送器/布局演示/android下单位/android下Junit/保存数据/android下权限/xml解析和序列化
- Android API之android.provider.ContactsContract.Data
- 《android开发艺术探索》读书笔记(十五)--Android性能优化
- macos安装android studio(Android Studio 2021.1.1)
- Android ---paint类
- [Android] After saving a media file, update media scanner
- Android开发指南(42) —— Adding Custom Suggestions
- 【VLC-Android】vlc-android简例
- Android 编译之android.bp详解
- Android【报错】android.content.ActivityNotFoundException:activity in yourAndroidManifest.?
- Android Fragment之间的切换
- Android 打开系统应用,如:拨号、短信、相机、相册等功能
- Android SQL删除表、清空表
- Android DatePicker 时间选择器
- android 10.0 更换壁纸加载慢滑动卡顿的解决
- Android JNI语法之--C++--list、set、map用法
- 【Android 安全】DEX 加密 ( Proguard 混淆 | 混淆后的报错信息 | Proguard 混淆映射文件 mapping.txt )
- Android 开源项目android-open-project解析之(三) ScrollView,TimeView,TipView,FlipView
- Android的ViewAnimator而它的子类ViewSwitcher-android学习之旅(三十三)
- Android Property Animation 物业动画
- Android培训班(60)dex文件格式
- Android kotlin 用RecyclerView(androidx+BRVAH3.0.6)实现从底部弹出列表对话框(单选/多选)功能
- Android Studio的报错提示:android.content.res.Resources$NotFoundException: Resource ID #0xfffffe6c
- Android JNI异常处理
- 基于Android 开发之Flutter框架
- android开发,Android Studio Build Output 输出的中文显示乱码