[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 日历的更多相关文章

  1. 实例源码--Android日历实例源码

      下载源码   技术要点: 1.Android基础控件的使用 2.Android应用开发基础框架 3.源码带有非常详细的中文 注释 ...... 详细介绍: 1. Android应用开 发技术 此套 ...

  2. android日历控件(一)

    自定义日历并且具备设置今天以前的时间不可点选,以前的颜色和当前的颜色不同,以及获取两次点击日期之间间隔的天数所以说细节比较多 个人习惯,先上图 靠,笔记本不知道怎么回事,禁用到触摸板之后 再次唤醒屏幕 ...

  3. Android 日历控件PickTime

    最近做项目,需要设置用户的生日,所以做这样一个功能. 开始发觉自带的 DatePicker 很是不好用. 上代码: <DatePicker android:id="@+id/dpPic ...

  4. Android日历视图(CalendarView)讲解-android学习之旅(三十六)

    CalendarView简介 CalendarView用于显示和选择日期,如果希望监听事件的改变可以用setOnDateChangeListener()方法. CalendarView属性介绍 代码示 ...

  5. Android 日历视图(Calendarview)

    1.介绍 2.常用属性 3.xml文件 <?xml version="1.0" encoding="utf-8"?> <LinearLayou ...

  6. DateTimePicker——开源的Android日历类库

    Github托管地址:https://github.com/flavienlaurent/datetimepicker

  7. Android日历开发之右上角标注红点事件

    1.效果如下所示: 2.方法:      前提:已经知道如何在右上角画圆点的情况下.      这是一个任务显示器,每个任务都有一个时间,比如2014.01.12.      如果要标注2016.08 ...

  8. android日历控件

    源码地址 : http://download.csdn.net/detail/abc13939746593/7265459

  9. phonegap之android原生日历调用

    android日历调用首先第一步我们要添加权限 <uses-permission android:name="android.permission.READ_CALENDAR" ...

随机推荐

  1. Vue组件之间通信的三种方式

    最近在看梁颠编著的<Vue.js实战>一书,感觉颇有收获,特此记录一些比价实用的技巧. 组件是MVVM框架的核心设计思想,将各功能点组件化更利于我们在项目中复用,这类似于我们服务端面向对象 ...

  2. 02使用常规步骤编译NanoPiM1Plus的Android4.4.2

    02使用常规步骤编译NanoPiM1Plus的Android4.4.2 大文实验室/大文哥 壹捌陆捌零陆捌捌陆捌贰 21504965 AT qq.com 完成时间:2017/12/5 17:51 版本 ...

  3. oracle in表达式参数支持最大上限1000个

    oracle in表达式参数支持最大上限1000个 方法是拆分为多个 col in ... or col in ... #region 解决大于1000的问题 private String getSu ...

  4. 使用openssl搭建CA并颁发服务器证书

    本来整理了一份执行脚本,但是没有找到附件功能.只好直接贴当时自己看过的链接了. 文章标题:Openssl Certificate Authority 转载链接:https://jamielinux.c ...

  5. HDU_1018_n(1e7)的阶乘的结果的位数

    http://acm.hdu.edu.cn/showproblem.php?pid=1018 Big Number Time Limit: 2000/1000 MS (Java/Others)     ...

  6. 前端零基础快速入门JavaScript

    JavaScript代码可以直接嵌在网页的任何地方,不过通常我们都把JavaScript代码放到<head>中: <html><head> <script&g ...

  7. day19-常用模块IV(re、typing)

    目录 re模块 typing模块 爬取音频 re模块 用来从字符串(文本)中查找特定的东西 1.元字符:有特殊意义的字符 ^ 从开头匹配 import re a = re.findall('^abc' ...

  8. 梦想CAD控件 2019.05.05更新

    下载地址: http://www.mxdraw.com/ndetail_20141.html 1. 增加vs2017版本控件 2. 增加windows触摸屏支持 3. 增加手写签名功能 4. 修改PL ...

  9. java虚拟机(六)--垃圾收集器和内存分配策略

    目前没有完美的收集器,不同的厂商.版本的虚拟机提供的垃圾收集器会有很大的差别,用户根据自己应用特点和要求组合出各个年代所使用 的收集器.基于jdk1.7Update14之后的虚拟机. HotSpot的 ...

  10. HEVC-HM16.9源码学习(1)TEncCu::xCompressCU

    函数入口:Void TEncSlice::compressSlice的m_pcCuEncoder->compressCtu( pCtu );调用xCompressCU( m_ppcBestCU[ ...