Coder Social home page Coder Social logo

amit-upadhyay-it / contacts-search-android Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 162 KB

A library which fetches the contacts from mobile and allows to search over it.

License: Apache License 2.0

Java 100.00%
contact-list contacts-app searchview android

contacts-search-android's Introduction

contacts-search-android

A library which fetches the contacts from mobile and allows to search over it.

To use this library:

  1. git clone https://github.com/amit-upadhyay-IT/contacts-search-android.git

  2. Change the first line of app level build.gradle file to: apply plugin: 'com.android.library'

  3. Sync the project

  4. Now you can use the Pre-defined classes for your purpose. EG: ContactsRecyclerAdapter, SearchActivity, etc;

  5. To request permissions you can use this code:

     public static final int MY_PERMISSIONS_REQUEST_READ_CONTACTS = 1;
    
     @Override
     public void onRequestPermissionsResult(int requestCode,
                                            String permissions[], int[] grantResults) {
         switch (requestCode) {
             case MY_PERMISSIONS_REQUEST_READ_CONTACTS: {
                 // If request is cancelled, the result arrays are empty.
                 if (grantResults.length > 0
                         && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
    
                     // permission was granted, yay! Do the
                     // contacts-related task you need to do.
                     displayContactsList();
    
                 } else {
    
                     // permission denied, boo! Disable the
                     // functionality that depends on this permission or ask for permission again.
                     ActivityCompat.requestPermissions(MainActivity.this,
                             new String[]{Manifest.permission.READ_CONTACTS},
                             MY_PERMISSIONS_REQUEST_READ_CONTACTS);
                 }
                 return;
             }
    
             // other 'case' lines to check for other
             // permissions this app might request
         }
     }
    

        if (ContextCompat.checkSelfPermission(MainActivity.this,
            Manifest.permission.READ_CONTACTS)
            != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(MainActivity.this,
                new String[]{Manifest.permission.READ_CONTACTS},
                MY_PERMISSIONS_REQUEST_READ_CONTACTS);
    }
    else
    {
        displayContactsList();
    }

License

    Copyright 2017 Amit Upadhyay

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

contacts-search-android's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.