CodeName OneShai Almog3 min readtutorialintermediate
Pick One Contact Without Asking for the Address Book
Summary
Codename One adds a permission‑free `ContactPicker` API that uses the Android 17 system contact picker and iOS `CNContactPickerViewController` to let apps request only the specific fields (name, phone, etc.) they need. The picker returns a snapshot `Contact` object without granting broad address‑book access, and the API gracefully falls back on older platforms or unsupported cases.
- Use `ContactPicker.setRequestedFields()` to declare needed fields (e.g., `NAME | PHONE`) and handle the result in the callback; the returned `Contact` is a one‑time snapshot.
- On Android 17+ the picker uses `ACTION_PICK_CONTACTS`; older Android falls back to `ACTION_PICK` with limited field support.
- iOS implementation uses `CNContactPickerViewController` and does not require `NSContactsUsageDescription` because the user selects data via a system UI.
- The API reports support via `ContactPicker.isSupported()`. When unsupported, apps should provide a manual entry UI.
Broad contacts permission is a privacy risk and a UX friction point. By limiting access to only the data a screen actually needs, developers can reduce permission prompts, improve user trust, and simplify compliance with platform privacy guidelines. The API also aligns with Android 17’s new privacy…
6/10