Search Google

Tuesday 23 December 2014

how to get user's contacts permission in android app

Services that cost you money —​receive and send SMS or MMS

Again with the costing me money.  And subscription SMS services are everywhere, so this is one to keep an eye on.  SMS apps Handcent or Chomp will need this, that makes sense, but what about an app that allows you to edit or take a picture and send it to a friend?  Yep, it's going to need to send MMS messages, too.  Same with something like a Mr. T soundboard (I pity the fool!) that lets you send a sound byte.  If an app is set up for you to share media, you might see this one listed as one of it's permissions.  If it's not, think twice about installing it.

contactsYour personal information — read your contacts

More scary sounding permissions, but let's think for a minute here.  Of course any messaging app is going to need this, that makes sense.  But a home screen contacts widget will need this, too.  As will apps like Twitter or Foursquare, so you can share tweets or check-in information over e-mail or SMS.  If an app doesn't have any social aspect, there's no need for this permission.



Public Constructors
Manifest.permission()
[Expand]
Inherited Methods
From class java.lang.Object

Constants


public static final String ACCESS_CHECKIN_PROPERTIES

Added in API level 1
Allows read/write access to the "properties" table in the checkin database, to change values that get uploaded.
Not for use by third-party applications.
Constant Value: "android.permission.ACCESS_CHECKIN_PROPERTIES" 
 
 

Request Permission to Read the Provider


To do any type of search of the Contacts Provider, your app must have READ_CONTACTS permission. To request this, add this <uses-permission> element to your manifest file as a child element of <manifest>:
    <uses-permission android:name="android.permission.READ_CONTACTS" />

Match a Contact by Name and List the Results


This technique tries to match a search string to the name of a contact or contacts in the Contact Provider's ContactsContract.Contacts table. You usually want to display the results in a ListView, to allow the user to choose among the matched contacts.

Define ListView and item layouts

To display the search results in a ListView, you need a main layout file that defines the entire UI including the ListView, and an item layout file that defines one line of the ListView. For example, you could create the main layout file res/layout/contacts_list_view.xml with the following XML:
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@android:id/list"
          android:layout_width="match_parent"
          android:layout_height="match_parent"/>
This XML uses the built-in Android ListView widget android:id/list.
Define the item layout file contacts_list_item.xml with the following XML:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@android:id/text1"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:clickable="true"/>
 
http://developer.android.com/training/contacts-provider/retrieve-names.html 

No comments:

Post a Comment