mirror of
https://github.com/apache/cordova-android.git
synced 2026-05-11 00:00:05 +08:00
Work on contacts
This commit is contained in:
@@ -1,43 +1,65 @@
|
||||
package com.phonegap.demo;
|
||||
|
||||
import android.provider.Contacts.People;
|
||||
import android.app.Activity;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentUris;
|
||||
import android.net.Uri;
|
||||
import android.database.Cursor;
|
||||
|
||||
public class ContactManager {
|
||||
|
||||
public void grabContacts()
|
||||
{
|
||||
Uri people = android.provider.Contacts.People.CONTENT_URI;
|
||||
Uri phone = android.provider.Contacts.Phones.CONTENT_URI;
|
||||
}
|
||||
|
||||
Activity mApp;
|
||||
Uri mPeople = android.provider.Contacts.People.CONTENT_URI;
|
||||
Uri mPhone = android.provider.Contacts.Phones.CONTENT_URI;
|
||||
Uri mEmail = android.provider.Contacts.ContactMethods.CONTENT_EMAIL_URI;
|
||||
|
||||
ContactManager(Activity app)
|
||||
{
|
||||
mApp = app;
|
||||
}
|
||||
|
||||
private void getColumnData(Cursor cur){
|
||||
|
||||
ContentResolver cr = getContentResolver();
|
||||
|
||||
|
||||
ContentResolver cr = mApp.getContentResolver();
|
||||
|
||||
if (cur.moveToFirst()) {
|
||||
|
||||
String name;
|
||||
String phoneNumber;
|
||||
int nameColumn = cur.getColumnIndex(People.NAME);
|
||||
String email;
|
||||
String phoneNumber;
|
||||
int nameColumn = cur.getColumnIndex(People.NAME);
|
||||
int phoneColumn = cur.getColumnIndex(People.NUMBER);
|
||||
String imagePath;
|
||||
|
||||
do {
|
||||
// Get the field values
|
||||
name = cur.getString(nameColumn);
|
||||
name = cur.getString(nameColumn);
|
||||
phoneNumber = cur.getString(phoneColumn);
|
||||
|
||||
|
||||
|
||||
|
||||
} while (cur.moveToNext());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void findContacts()
|
||||
{
|
||||
|
||||
// Form an array specifying which columns to return.
|
||||
String[] projection = new String[] {
|
||||
People._ID,
|
||||
People.NAME,
|
||||
People.NUMBER
|
||||
};
|
||||
|
||||
// Make the query.
|
||||
Cursor managedCursor = mApp.managedQuery(mPeople,
|
||||
projection, // Which columns to return
|
||||
null, // Which rows to return (all rows)
|
||||
null, // Selection arguments (none)
|
||||
// Put the results in ascending order by name
|
||||
People.DISPLAY_NAME + " ASC");
|
||||
|
||||
this.getColumnData(managedCursor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user