So i have this problem of not getting accurate time result from timepicker declared in xml, not the dialog thing, i just wanted to know what is the difference from the two. so that i can know which is better to use on my app, mainly i use the timepicker to set an alarm or a reminder, because i have a hunch that the timpicker declared in xml is just for UI use not really for functionality. because i keep on getting the wrong result, specially dealing with AM and PM, Scenario is that when using timepicker declared in xml (not the dialog), i change first the hour den minutes and lastly the AM and PM, but i won't correctly give me the current time, say i chose 7:30 PM supposedly the value of the hour must be 19 since its 24-hour but instead it gives me 7:30 AM i won't change the AM and PM part thus giving me a wrong result, if you go the other way around, it works, it gives me ang accurate result.
SO my question is what is the MAIN difference between the two timepickers, is it for show(timepicker xml declared) and timepicker(dialog)
Please refer to this post for this problem, i just came across this thread and it is really the same with my problem. its a bug issue in Android
Android TimePicker AM/PM button not invoking onTimeChanged
Related
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've developed an xposed module for whatsapp.
http://forum.xda-developers.com/xposed/modules/mod-whatsapp-extensions-add-extra-t3452784
I wanted to add feature to hide our own last seen still see others or report a fake last seen for eg: 1 Jan 1970.
I made following assumptions:
To do that first I hooked date and System.currentTimeInMillis methods to make whatsapp think its 1 Jan 1970. That worked but still last seen was shown perfectly.
Assumption: The last seen time value is directly taken from the server
Then I looked in the source to find where last_seen preference is referenced. Turns out it is only referenced in SettingsPrivacy activity's class.
Assumption: To hide our last seen and still see others we need to change last seen preference to 'visible to all' and turn that back to off once we get the last seen.
but the problem is it uses onPreferenceChangeListener. We cannot hook a method from the interface directly.
I cannot find the subclass which implements onPreferenceChangeListener as the classes shown in code are synthetic.
Please if anyone can help me with this, it will be great. I need to find which is preferencechangelistener for that preference. Rest I will manage.
This is kind of a brute force trick to get the implementation but I guess you can hook the app ClassLoader.loadClass and for each loaded class check if it implements the interface. If so hook its onPreferenceChangeListener.
I found a way to do it and its working.
http://forum.xda-developers.com/xposed/modules/mod-whatsapp-extensions-add-extra-t3452784
The way to do it is by hooking a method which takes a preference as argument. We create a preference ( com.whatsapp.preference.WAprivacy preference to be precise ) and then pass this preference with last seen set to desired value to the method. And we are done.
It is working so far.
In my android app, I need settings to select time range (e.g. 2 to 4 minutes, 8 to 12 minutes etc).
To implement it, I used two instances of ListPreference, one to select minimum time and other to select maximum time.
As maximum time cannot be less than minimum time, I want to update the maximum time list preference whenever minimum time is changed by a user.
To achieve it, I am using Preference.OnPreferenceChangeListner. When user changes minimum time preference, the listener callback function is called and in the callback, I call setEntries(), setEntryValues() and setValueIndex() on maximum time ListPreference instance.
The problem is that GUI of maximum time preference is not updated immediately when I do above. I can still see old entries in the preference. If I exit settings activity and launch the settings again, I can see updated entries and values.
Please let me know how I could solve this issue.
Also, please suggest if there is any better way to handle such settings use case.
Thanks.
After some more debugging, I realized my mistake.
I did not read this document of OnPreferenceChangeListener callback:
"Called when a Preference has been changed by the user. This is called before the state of the Preference is about to be updated and before the state is persisted."
The problem was that I was querying the value of minimum time list preference in the preference change listener callback of it and generating the entries of maximum time list preference on the bases of that. But as the document reads, new value of minimum time list preference was not yet set in the callback, so the entries were generated on the basis of old values. So it was not supposed to work as I was expecting.
Sorry for not posting code as it required more effort to make the code ready for posting here.
Thanks for reading my question.
How do you show hours in chronometer.By default its format is (hh:mm:ss), doesn't show in the view.I need it to show like 00:00:00 , and update the time.
I also require to pause the time and resume the time.
You must have to see at documentation to see how to use format for Chronometer.
This thread could also help you to see an implementation of a chronometer.
I'm looking to create something EXACTLY like TimePickerDialog (look and feel) in Android, but it would be for MINUTES/SECONDS, not HOURS/MINUTES. Therefore AM/PM would not be relevant and would therefore allow MINUTE to be greater than 24 (making the max 59).
Is it possible to change the TimePickerDialog instance in any way to reflect this?
Any and all suggestions would be greatly appreciated. :-)
Is it possible to change the TimePickerDialog instance in any way to reflect this?
No, but the layout and source code to TimePickerDialog are both available as a starting point for implementing your own dialog.
This might help:
TimePicker with seconds:
https://github.com/IvanKovac/TimePickerWithSeconds
Have a look.
As the links in CommonsWare's answer are now dead, you might want to know that the source for TimePickerDialog is probably already on your local machine - it is included in the SDK. Try looking in the following locations:
[SDK_HOME]/sources/android-23/android/app/TimePickerDialog.java
or
[SDK_HOME]/sources/android-23/com/android/datetimepicker/time/TimePickerDialog.java
[SDK_HOME]/platforms/android-23/data/res/layout/time_picker_dialog.xml
Of course, choose the Android version that you want to borrow from. References to R. should be to android.R. Unfortunately, there seem to be some visibility issues with ValidationCallback - even on recent SDK levels.