Building Apps with UserInfo & Sign-In
1 Accessing Contacts Data
- user’s contacts information
- the data by calling
ContentResolver
methods or by sending intents to apps
1.1 Retrieving a List of Contacts
- match by contact name
- match any type of contact data
- math a specific type of contact data, such as a phone number
1.1.1 Request Permission to Read the Provider
- to do any type of search of the Contacts Provider, request
READ_CONTACTS
permission
<uses-permission android:name="android.permission.READ_CONTACTS">
1.1.2 Match a Contact by Name and List the Results
Define ListView and item layouts
@android:id/list, @android:id/text1
1.1.2.1 Define a Fragment that displays the list of contacts
ContactContract
defines useful constacts and methods for accessing the provider- define your own constants for content URIs, table names or columns
- use a
CursorLoader
to retrieve data from the provider, implementLoaderManager.LoaderCallbacks
- implement the adapter interface
AdapterView.onItemClickListener
1.1.2.2 Define global variables
1.1.2.3 Initialize the Fragment
inflater.inflate(R.layout.contact_list_fragment, container, false);
1.1.2.4 Set up the CursorAdapter for the ListView
contactsList = (ListView) getActivity().findViewById(R.layout.contact_list_view);
cursorAdapter = new SimpleCursorAdapter(getActivity(), R.layout.contact_list_item, null, FROM_COLUMNS, TO_IDS, 0);
contactsList.setAdapter(cursorAdapter);
1.2 Retrieving Details for a Contact
1.3 Modifying Contacts Using Intents
1.4 Displaying the Quick Contact Badge
2 Adding Sign-In
- 相同凭证登录googleGoogle Android API
- 将登录和社交功能整合到app中。
2.1 Key Developer Features
- Trusted authentication,google登录是一个简单,可信安全的方式。Add Sign-in
- Access the profile and social graph.