android-calendar

Android Calendar illegalArgumentException when calendar.month set to 1

半世苍凉 提交于 2020-01-30 02:41:07
问题 The code below works fine except when calendar.MONTH set to 1 (Feb) ,and I do not know why ? Thanks. Calendar calendar = Calendar.getInstance(); calendar.setLenient(false); calendar.set(Calendar.YEAR, 2013); calendar.set(Calendar.MONTH, 1); // Only when "Feb" failed with illegalArgumentException int maxDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); <= If Calendar.MONTH set to 1, this line will "java.lang.IllegalArgumentException" 回答1: You're getting the current date in getInstance.

CalendarContract Events : bad id inserted, Calendar corrupted in Android

让人想犯罪 __ 提交于 2020-01-16 05:52:01
问题 I made a mistake on testing insert Events using CalendarContract. I set my own _ID in a Events insert. values.put(Events._ID, "156498713465"); Now, all my new events are created with a bad id (for exemple -535191590). When I click to the event in the Google Calendar Application, it crash. I have the same error as this thread : Calendar corrupted in Android I tried to delete all bad events : activity.getContentResolver().delete(Events.CONTENT_URI, Events._ID + " > ? ", new String[] { "10000" }

How do I display events to a specific date and time in a MaterialCalendarView?

随声附和 提交于 2020-01-16 03:50:31
问题 I am testing out a sample app where I am trying to achieve displaying time and date to a specific day.Currently, it just plots to the entire month even if the event if for a day. Say if the event if from 9:30am to 10:30am on Jan 5, it will show up for the entire month, rather than just for Jan 5th. Want to achieve something like this: Currently my app shows it for the whole month, even if its jan 1 or jan 8 event ( here's a screenshot where it wrongly shows up on the week of jan 15 for

How to add color for android calendar events?

 ̄綄美尐妖づ 提交于 2020-01-14 04:04:15
问题 I want to add color for android calendar events, i have used the following code ContentResolver cr = context.getContentResolver(); ContentValues values = new ContentValues(); values.put(Events.DTSTART, startMillis); values.put(Events.DTEND, endMillis); values.put(Events.TITLE, phNumber); values.put(Events.DISPLAY_COLOR, 0xffff0000); values.put(Events.CALENDAR_ID, calID); values.put(Events.EVENT_TIMEZONE, "UTC"); Uri uri = cr.insert(Events.CONTENT_URI, values); But this code is not added color

calendarview highlights wrong week

余生颓废 提交于 2020-01-13 16:27:23
问题 I have a CalendarView in my app, when the user selects a date by touching that date in the monthview, the correct date is selected (verified by adding debug statements in the code), but the week before is highlighted, so it looks as if the wrong date is selected. I have found a work-around: if I set 'firstDayInWeek' to 1 the problem is solved, but by default the firstDayInweek is 2 (monday), and then this problem occurs. Thank you very much! Samsung S4 with API 21 回答1: I have had the same

calendarview highlights wrong week

心已入冬 提交于 2020-01-13 16:26:12
问题 I have a CalendarView in my app, when the user selects a date by touching that date in the monthview, the correct date is selected (verified by adding debug statements in the code), but the week before is highlighted, so it looks as if the wrong date is selected. I have found a work-around: if I set 'firstDayInWeek' to 1 the problem is solved, but by default the firstDayInweek is 2 (monday), and then this problem occurs. Thank you very much! Samsung S4 with API 21 回答1: I have had the same

Display multiple dates on calendar

时间秒杀一切 提交于 2020-01-06 05:25:30
问题 I'm implementing an android app. In which, I have to display some available(getting from the web service) date slots on calendar and available date slots color will be different and seleted date slot color will be different and if user click on one of the given date so the selected date color will be change. I'm not getting how to do that without third party libraries. I can't use third party libraries. I have used DatePickerDialog but using this I'm able to select any date. I'm unable to

how to get start time of an event from android calendar

余生颓废 提交于 2020-01-03 19:07:35
问题 How to get StartTime and EndTime from an event from android calendar ? I am using this code for get all the data of the event but it gives me StartDate and EndDate but i need Date + Time of both Start and End . here's the code CalNames[i] = "Event" + cursor_event.getInt(0) + ": \nTitle: " + cursor_event.getString(1) + "\nDescription: " + cursor_event.getString(2) + "\nStart Date: " + new Date(cursor_event.getLong(3)) + "\nEnd Date : " + new Date(cursor_event.getLong(4)) + "\nLocation : " +

how to get start time of an event from android calendar

社会主义新天地 提交于 2020-01-03 19:06:16
问题 How to get StartTime and EndTime from an event from android calendar ? I am using this code for get all the data of the event but it gives me StartDate and EndDate but i need Date + Time of both Start and End . here's the code CalNames[i] = "Event" + cursor_event.getInt(0) + ": \nTitle: " + cursor_event.getString(1) + "\nDescription: " + cursor_event.getString(2) + "\nStart Date: " + new Date(cursor_event.getLong(3)) + "\nEnd Date : " + new Date(cursor_event.getLong(4)) + "\nLocation : " +

Scheduling more than one pendingIntent to same activity using AlarmManager

余生颓废 提交于 2020-01-03 17:29:53
问题 Recently I noticed strange behaviour when i tried to schedule Activities to be run in the future using AlarmManager. Look at the code below, the first activity is started in 20 seconds, while the second activity is not started in 40 seconds instead it is started only after 60 seconds. Can anyone explain why the second intent doesn't schedule the second activity to be called instead the third intent does. Does this mean that i can have only one intent for an activity in the AlarmManager. /