Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Has Android any API to provide Date-time as input from user (startActivityForResult)? [closed]

Tags:

android

api

I'm looking for API that provide Date-time info defined by user. I used in the past Contact List like:

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

and on onActivityResult by 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 name, phone and gmail.

enter image description here

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

enter image description hereenter image description here

I don't want to implement it by myself since this feature exists (only in case if no API)

Any ideas?

like image 589
Maxim Shoustin Avatar asked Oct 20 '12 09:10

Maxim Shoustin


1 Answers

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

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

  • https://code.google.com/p/android-dateslider/
  • https://code.google.com/p/android-wheel/
  • https://code.google.com/p/scroll-picker-view-for-android/
  • ...

(Use Android UI patterns app https://play.google.com/store/apps/details?id=com.groidify.uipatterns&hl=es to find libraries like these)

like image 98
molnarm Avatar answered Sep 20 '22 08:09

molnarm