I am implementing a DateTimePicker. I have reuse this repository.
The problem appears when I am trying to catch the events for the onTimeChanged() method when I change the minutes. If I use the buttons of + and – it's fine, the event is fired and I can handle it here:
public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
// Update the internal Calendar instance
mCalendar.set(mCalendar.get(Calendar.YEAR),
mCalendar.get(Calendar.MONTH),
mCalendar.get(Calendar.DAY_OF_MONTH),
hourOfDay, minute);
}
Whereas when I click on the minutes and I change it using the keyboard the event doesn't arise, as in the case of the hours, days, etc…
A more detail description of the problem is:
What steps will reproduce the problem?
Select the time picker
Touch on the numbers, so the keyboard appears
when I write an amout of minutes, the event doesn't fire
What is the expected output? What do you see instead?
I would expect to catch this event inside onTimeChanged(), but I cant.
What version of the product are you using? On what operating system?
Version 2. On Android Froyo.
The author of this code has told me there is a bug on Android. I think should be a work around to this problem, for example creating my own class extending from TimePicker and reimplementing the interface OnTimeChangedListener.
What is the best option to listen the timerPicker events?
DatePicker control must call clearFocus() in order to trigger
onFocusChanged() and that will fix the issue.
PFB the link that might help you :
http://code.google.com/p/android/issues/detail?id=2745
Thanks!
The event is fired in the same way as the onchange Event in HTML:
It only fires after leaving the text boxes, and going to the next one.
I can't tell if it's really a bug or some kind of feature.
You could just catch the KeyEvent.Callback when extending the TimePicker class. Then you should get informed about every single key press inside the EditText controls internally used by the TimePicker.
Related
I am trying to add a button to my app that allows someone to add an assignment to their calendar. I am doing this using an Intent and CalendarContract. Everything is working correctly, in that it launches the calendar app in the add an event state and all of the information is in the correct field and displaying properly. The only thing that I am having a problem with is the
CalendarContract.EXTRA_EVENT_ALL_DAY to true
isn't making it default to an all day event.
I have tried separating it out into multiple .putExtra statements, as well as tried individual components, but none of that seems to make any difference.
startActivity(Intent(Intent.ACTION_EDIT)
.setData(CalendarContract.Events.CONTENT_URI)
.setType("vnd.android.cursor.dir/event")
.putExtras(
bundleOf(
CalendarContract.Events.TITLE to assignment.getItemText(),
CalendarContract.Events.DESCRIPTION to "${assignment.beginDate.takeIf { it != null }?.let {
"${getString(R.string.start_date)}: ${it.format("MMM dd, h:mm a")}\n\n"} ?: ""}${getString(R.string.due_date)}: ${assignment.dueDate.format("MMM dd, h:mm a")}\n\n${assignment.getDetailText()}",
// If there is just one time, put it in for both so that the generated event in the calendar app has logical and related start/end times
CalendarContract.EXTRA_EVENT_BEGIN_TIME to (assignment.beginDate?.time ?: assignment.dueDate.time),
CalendarContract.EXTRA_EVENT_END_TIME to assignment.dueDate.time,
CalendarContract.EXTRA_EVENT_ALL_DAY to true
)
)
)
I expected that this would allow me to go to add an event that has all day selected but it doesn't default to that.
I have noticed that this issue only occurs with Google Calendar
Any help would be great thanks.
This seems to be a bug in the current version of Android's integration with Google Calendar. Hopefully they will have a bug fix out in a patch release soon. It's definitely working in all other calendars that I've tested
Situation:
I need to create a program that shows current date and updates some date(that is NOT CURRENT date,it is past date) according to current time(for example after 23:59,date refreshs). In other words,it is simple application,that shows date in the past and time.
What did I try?
I have found TextClock for this. It can show current time,but I cannot track over it.
So what can I do? I need to create my own clock class or use Timer and TimerTask? Do I need a Service?
I think, if I understand you correctly, you're on the right path. I wasn't familiar that there was even a TextClock view, but it looks pretty basic and will just work for displaying the current time.
Instead, maybe use a TimerTask to update the UI every second, or so, and set one TextView with the current time and another with your other time that's an offset of the current time (current = new Calendar(); current.add(Calendar.MINUTE, 1); )
You could use TimerTask, and that'd be pretty easy compared to rolling your own thread or using an AsyncTask. Get the current time, set it to one text view, manipulate that time variable and set it to the other text view.
I am trying to get real time changes on a document using the changelistener, however i have to refresh tha mobile app to see the change. Here is my gist https://gist.github.com/mikekaraa/89416ea8b074c71d7153
Please help me out if you have a solution
Would you tie your ChangeListener() event to a time interval such that e.g after every 3 or 5 seconds it is fired and triggers the next sequence of events if at all the document changed within that time span.
I hope that helps.
I am writing an application that needs to know when a meeting is added/removed/changed in the calendar.
I know how to get all the data from a calendar using CursorLoader on the calendar uri.
Also i know how to listen to calendar changes using the ContentObserver.
The problem is that the ContentObserver.onChange(boolean selfChange, Uri uri) does not provide information on the changed event. so the only way for me to know what the change was is to load again the entire calendar (or part of it) using the CursorLoader and comparing the old with the new.
Is there a way to "register for changes" on the calendar and receive the events that were changed?
Unfortunately, there is no such option. I even went as far as to reflect the entire Bundle which came with that Intent - nothing. IMHO, some surfaces of the Android API are quite lacking, this is just one of these instances, I guess.
Each event after manual editing event sets CalendarContract.DIRTY = 1 (used to indicate that local, unsynced, changes are present). Find these events. Don't forget to reset this flag (equal 0) after synchronization.
When should I use past tense on event listener? If you check the android link below, you can see onFocusChange on View and onFocusChanged on WebView. Which one should be more appropriate and why android choose present tense on View and pass tense on WebView?
http://developer.android.com/reference/android/view/View.OnFocusChangeListener.html
http://developer.android.com/reference/android/webkit/WebView.html
The onFocusChange in the example looks more like a lapse in the method naming and was likely meant to read onFocusChanged. In both examples (according to the docs) the event is sent after the action has taken place. Thus past tense would be appropiate.
Events that are sent after the action has taken place that they inform about should use past tense. If events are sent before the action takes place you probably don't want to use past tense. beforeFocusChange or focusAboutToChange are patterns that I've come across.