Синхронизирайте телефонните контакти с приложението Database Android

и в момента работя върху приложение за Android, което синхронизира контактите на потребителите и показва тези хора като приятели на потребителя, които са в контакт чрез търсене в базата данни. Това използва много подобна техника като whatsapp. Аз съм нов в това. И ако някой може да ми помогне, ще бъде много любезен. Моля, кажете ми откъде трябва да започна. Също така, моля, дайте ми някаква справка за това. всяка помощ ще бъде appriciable.Please да помогне. Благодаря предварително :-))))


person user3781907    schedule 11.10.2014    source източник


Отговори (1)


Започнете от Доставчик на контакти

В крайна сметка трябва да използвате

new CursorLoader(getActivity(),
                contentUri,
                ContactMobileNumbQuery.PROJECTION,
                ContactMobileNumbQuery.SELECTION,
                null,
                ContactMobileNumbQuery.SORT_ORDER);

Горният код извлича всички телефонни номера с име, като използва интерфейса по-долу във вашия курсор

/**
 * This interface defines constants used by mobile number retrieval queries.
 */
public interface ContactMobileNumbQuery{
    final static int QUERY_ID = 1;

    //A Content Uri for Phone table
    final static Uri CONTENT_URI = Phone.CONTENT_URI;   

    //The search or filter query Uri
    final static Uri FILTER_URI = Phone.CONTENT_FILTER_URI;

    // The selection clause for the CursorLoader query. The search criteria defined here
    // restrict results to contacts that have a phone number and display name.
    // Notice that the search on the string provided by the user is implemented by appending
    // the search string to CONTENT_FILTER_URI.
    final static String SELECTION = Phone.HAS_PHONE_NUMBER + "=1" + " AND " + Phone.DISPLAY_NAME_PRIMARY + "<>''";

    // The desired sort order for the returned Cursor - Order by DISPLAY_NAME_PRIMARY 
    //in Ascending with case insensitively
    final static String SORT_ORDER = Phone.DISPLAY_NAME_PRIMARY + " COLLATE NOCASE ASC";

    // The projection for the CursorLoader query. This is a list of columns that the Contacts
    // Provider should return in the Cursor.
    final static String[] PROJECTION = {

        // The contact's row id
        Phone._ID,

        // the Contacts table contains DISPLAY_NAME_PRIMARY, which either contains 
        // the contact's displayable name or some other useful identifier such as an 
        // email address.
        Phone.DISPLAY_NAME_PRIMARY,

        // A pointer to the contact that is guaranteed to be more permanent than _ID. Given
        // a contact's current _ID value and LOOKUP_KEY, the Contacts Provider can generate
        // a "permanent" contact URI.
        Phone.LOOKUP_KEY,

        //Phone number of the contact
        Phone.NUMBER,
    };
    // The query column numbers which map to each value in the projection
    final static int ID = 0;
    final static int DISPLAY_NAME = 1;
    final static int LOOKUP_KEY = 2;
    final static int NUMBER = 3;
}

Логиката за синхронизиране трябва да бъде написана отделно. Опитайте и напишете вашите коментари :)

person Sathish    schedule 11.10.2014
comment
Маркирайте го като правилен отговор, ако наистина решава проблема ви :-) - person Sathish; 13.10.2014