android_contact_picker


Source link: https://github.com/codinguser/android_contact_picker

Why?

Often in Android development, there is need to support the following workflow:

  1. Display list of contacts
  2. User selects a contact
  3. Display contact details
  4. User selects a phone number
  5. Perform an action with the number

There is a standard way to call the contact list in Android, but this does not always feel well-integrated in your app and does not work well expecially for tabbed Android applications.

ContactPicker is an Android library which allows you to easily integrate the above workflow in your application with minimal effort. It uses the new Fragments API and asynchronous contact loading introduced in the newer versions of Android.

This library requires a minimum of Android API level 8 and above since it uses the new contact APIs introduced in Android 2.0

Installation

In order to use the library, add the following line to your Gradle dependencies:

  compile 'com.codinguser.android:contactpicker:3.0.0@aar'  

Usage

There are two ways to use the library.

  1. If you just want to open a contacts picker from within your app and then get a number, do this:

    private static final int GET_PHONE_NUMBER = 3007;  public void getContact() {
    
     startActivityForResult(new Intent(this, ContactsPickerActivity.class), GET_PHONE_NUMBER);
     
    }
    
    // Listen for results. @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data){
    
      // See which child activity is calling us back.
      switch (requestCode) {
    
    case GET_PHONE_NUMBER:
    
     // This is the standard resultCode that is sent back if the
    
     // activity crashed or didn't doesn't supply an explicit result.
    
     if (resultCode == RESULT_CANCELED){
    
      Toast.makeText(this, "No phone number found", Toast.LENGTH_SHORT).show();
    
     
    }
    
      else {
    
      String phoneNumber = (String) data.getExtras().get(ContactsPickerActivity.KEY_PHONE_NUMBER);
    
     //Do what you wish to do with phoneNumber e.g.
    
      //Toast.makeText(this, "Phone number found: " + phoneNumber , Toast.LENGTH_SHORT).show();
    
    
     
    }
    
    default:
    
     break;
      
    }
     
    }
     
  2. If you have a tabbed application with multiple activities in Android and you wish to make a contacts list as one of the tabs, then your contacts activity should subclass the ContactsPickerActivity and override the OnContactNumberSelected method in order to get notified when a number is selected. The default implementation of OnContactNumberSelected just sets the number as a result and finishes the activity, so make sure to override it to do what you want.

License

The code is provided under an MIT license, so get hacking!!

Acknowledgements

Thanks to Avi Hayun for feedback used to improve the library

Contact

For any inquiries, you can reach me at [email protected]

Resources

A custom Password Input with animation for Android.

Contributions, stars, followers, trending etc. on Github.

Glass-break effect for views.

A view to draw Bezier curves.

A simple wheel view for Android.

An Android library to make thumbs +1 effect. It supports text and images.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes