Does Android have any API to provide date-time as user input (startActivityForResult)?

I am looking for an API that provides user-defined date information. I used in the past the Contact List, for example:

Intent intent = new Intent(Intent.ACTION_PICK); intent.setType(ContactsContract.Contacts.CONTENT_TYPE); ((Activity) mContext).startActivityForResult(intent, LauncherUI.RESULT_GOT_CONTACT_INFO); 

and onActivityResult using

 Uri contactData = intent.getData(); //Cursor cursor = managedQuery(contactData, null, null, null, null); Cursor cursor = cr.query(contactData, null, null, null, null); cursor.moveToFirst(); String name = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); String id = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.Contacts._ID)); 

I could extract the name, phone and gmail.

enter image description here

Now my goal is to do the same for Date-time with the format YYYY-MM-DD hh: mm: ss. Something like:

enter image description hereenter image description here

I do not want to implement it myself, since this function exists (only if there is no API)

Any ideas?

+7
source share
1 answer

Yes, Android has built-in date and time dialogs, see this article for details (it uses fragments, but you can just use DatePickerDialog and TimePickerDialog ).

You can also use other open source libraries with a cool data collector:

(use the Android UI app https://play.google.com/store/apps/details?id=com.groidify.uipatterns&hl=es to find such libraries)

+7
source

All Articles