android-calendar

Android Calendar: onActivityResult's resultCode is always 0

走远了吗. 提交于 2019-12-07 04:46:44
问题 I develop an Android application that prompt the calendar application to edit events. I use startActivityForResult() to open the Calender. After editing and saving the event, resultCode is always 0 inside onActivityResult() . I saw many answers related to "onActivityResult resultCode always returns 0". This is because of not using the setResult() and finish() in the 2nd activity. But in my case, I am calling the Android calendar application (not a custom activity). The code to prompt the

Problem with Calendar.get(Calendar.HOUR)

Deadly 提交于 2019-12-07 03:59:24
问题 I am trying to display in a TextView when my application last updated (e.g., "Last updated at 12:13). I am trying to use a Calendar instance and I thought I understood it correctly but I seem to be having trouble. I know to get an instance I use the method Calendar.getInstance(). And then to get the hour and minute I was using Calendar.get(Calendar.HOUR) and Calendar.get(Calendar.MINUTE). My minute field returns correctly but Calendar.HOUR is returning the hour on a 24 hour clock and I want a

how to change ringer mode in background(Vibrate or Silent)

耗尽温柔 提交于 2019-12-06 11:24:16
I'm trying to write a program in which user can set time that will change ringer mode to vibrate or normal in background. When I set the start time it's working but at the end time it's not changing and device continuing vibrate mode. I just want, at the start time phone would be in vibrate and at end time phone would go back into the silent mode. MainActivity.java public class MainActivity extends Activity { private PendingIntent pendingIntent; private AlarmManager alarmManager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R

Specify calendar in Android event creation intent

≯℡__Kan透↙ 提交于 2019-12-06 09:31:46
I trigger the creation of a calendar event through the following piece of code: Intent intent = new Intent(Intent.ACTION_INSERT); intent.setData(CalendarContract.Events.CONTENT_URI); startActivity(intent); But I would like to specifiy which calendar should be used for the event creation (i.e set the initial value of the calendar dropdown in the event creation screen). I've tried to provide ACCOUNT_TYPE , ACCOUNT_NAME and CALENDAR_ID intent.putExtra(CalendarContract.Events.ACCOUNT_TYPE, accountType); intent.putExtra(CalendarContract.Events.ACCOUNT_NAME, accountName); intent.putExtra

How to show only a specific month on Android CalendarView?

血红的双手。 提交于 2019-12-06 02:09:34
I want to show a specific month on CardView without NEXT and PREVIOUS arrow to navigate the calendar. If I want to show February 2010 user must see only February 2010. They can't go next or previous month. I followed this Stack Overflow answer to show a specific month but it's not working for me. It shows all time the current date and month for my case. I'm not sure is it possible or not to disable NEXT-PREVIOUS navigation. My XML: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"

Why CalendarProvider doesn't allow writing ExtendedProperties?

…衆ロ難τιáo~ 提交于 2019-12-06 01:47:34
Google calendar events have extended properties that can be used to attach name/value pairs to an event. We are implementing a collaborative calendar application that uses those extended properties to attach extra information to the event. As recommended by Google, we use the Android CalendarProvider to read and create new events. When we create a new event we need to add some extended properties to it but we just realised that the calendar provider doesn't allow writing CalendarContract.ExtendedProperties , if we try we get the following error: Only sync adapters may write using content://com

Getting data from calendar on Android Wear

六眼飞鱼酱① 提交于 2019-12-05 20:06:00
I'm querying the calendar data like this: // Constructor of the class mCursor = context.getContentResolver().query(CalendarContract.Events.CONTENT_URI, mColumns, null, null, null); updateEvents(); //contents of updateEvents: events.clear(); mCursor.moveToFirst(); mLastUpdate = System.currentTimeMillis(); while (!mCursor.isAfterLast()) { long end = mCursor.getLong(2); if (end > mLastUpdate) events.add(new Event(mCursor)); mCursor.moveToNext(); } The code manages works on mobile device, however when it's run on a Wear device there appears to be no data. I've found a WaerableCalendarContract ,

How do I change the background color of calendar dates in MaterialCalendarView

家住魔仙堡 提交于 2019-12-05 19:09:02
I'm trying to change the background color of dates using a JSON response I get. But I'm having some difficulty. Here is my code: <com.prolificinteractive.materialcalendarview.MaterialCalendarView android:id="@+id/calendarView" android:layout_width="match_parent" android:layout_height="300dp" android:layout_marginBottom="16dp" android:layout_marginTop="16dp" /> MainActivty.java public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

calendarview highlights wrong week

╄→гoц情女王★ 提交于 2019-12-05 18:32:49
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 I have had the same issue as you, using a Samsung S5 running API 21. There are two workarounds that I have found, none of them is a

Android- Remove Calendarview from DatePickerDialogFragment

懵懂的女人 提交于 2019-12-05 16:36:00
I have a Datepickerdialog fragment which works fine.When i click the button the datepickerdialog opens whixh has spinner date selection on the left side and calendar view on the right side. For my app in one place i want just the spinner date selection part alone to be shown(calendar view part must be removed or hidden) In other place i want calendar view part must be shown and the spinner date selection must be hidden or removed. But i tried a lot with various things like for hiding calendar view like Method m = minDateSelector.getClass().getMethod("setCalendarViewShown", boolean.class); m