项目:PeSanKita-android
文件:ContactAccessor.java
private ContactData getContactData(Context context,String displayName,long id) {
ContactData contactData = new ContactData(id,displayName);
Cursor numberCursor = null;
try {
numberCursor = context.getContentResolver().query(Phone.CONTENT_URI,null,Phone.CONTACT_ID + " = ?",new String[] {contactData.id + ""},null);
while (numberCursor != null && numberCursor.movetoNext()) {
int type = numberCursor.getInt(numberCursor.getColumnIndexOrThrow(Phone.TYPE));
String label = numberCursor.getString(numberCursor.getColumnIndexOrThrow(Phone.LABEL));
String number = numberCursor.getString(numberCursor.getColumnIndexOrThrow(Phone.NUMBER));
String typeLabel = Phone.getTypeLabel(context.getResources(),type,label).toString();
contactData.numbers.add(new NumberData(typeLabel,number));
}
} finally {
if (numberCursor != null)
numberCursor.close();
}
return contactData;
}
项目:Raffler-Android
文件:RegisterUserActivity.java
private void loadUserInfoFromPhone(){
User user = AppManager.getSession();
if (user != null) {
etName.setText(user.getName());
Util.setProfileImage(user.getPhoto(),imgProfile);
} else {
if (checkPermissions()) {
String[] projection = new String[] {
Phone.disPLAY_NAME,Phone.HAS_PHONE_NUMBER,Phone.NUMBER,Phone.CONTACT_ID};
Cursor cursor = getApplication().getContentResolver().query(ContactsContract.Profile.CONTENT_URI,null);
if (cursor.movetoFirst()){
etName.setText(cursor.getString(cursor.getColumnIndex("display_name")));
}
cursor.close();
}
}
}
项目:Cable-Android
文件:ContactAccessor.java
private ContactData getContactData(Context context,number));
}
} finally {
if (numberCursor != null)
numberCursor.close();
}
return contactData;
}
项目:Chit-Chat
文件:MessageUtils.java
public static void sendContactDetails(Context context,String ph_no,ContactItemDataModel contactData,Uri uri) {
Cursor cursor = context.getContentResolver().query(uri,null);
if (cursor != null && cursor.movetoFirst()) {
String phoneNo = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));
String name = cursor.getString(cursor.getColumnIndex(Phone.disPLAY_NAME));
if (phoneNo == null) phoneNo = "";
if (name == null) name = "";
JsonObject contact_message = new JsonObject();
contact_message.addProperty("name",name);
contact_message.addProperty("number",phoneNo);
SendMessageService.startSendTextMessage(context,ph_no,contactData.getContact_id(),contact_message.toString(),"contact",contactData.is_bot(),Utils.getCurrentTimestamp());
}
}
项目:aaikya
文件:AddPersonActivity.java
@Override
public void onActivityResult(int requestCode,int resultCode,Intent data) {
// Check which request we're responding to
if (requestCode == REQUEST_CONTACTS) {
// Make sure the request was successful
if (resultCode == RESULT_OK) {
Uri uri = data.getData();
String[] projection = { Phone.disPLAY_NAME };
try (Cursor cursor = getContentResolver().query(uri,projection,null)) {
if (cursor == null || cursor.getCount() <= 0) {
Log.e(TAG,"Null cursor found. Weird! Probably no contact was picked");
return;
}
cursor.movetoFirst();
int nameColumnIndex = cursor.getColumnIndex(Phone.disPLAY_NAME);
String name = cursor.getString(nameColumnIndex);
nameField.setText(name);
}
}
}
}
项目:TextSecure
文件:ContactAccessor.java
private ContactData getContactData(Context context,number));
}
} finally {
if (numberCursor != null)
numberCursor.close();
}
return contactData;
}
项目:TextSecure
文件:ContactAccessor.java
public List<String> getNumbersForThreadSearchFilter(String constraint,ContentResolver contentResolver) {
LinkedList<String> numberList = new LinkedList<String>();
Cursor cursor = null;
try {
cursor = contentResolver.query(Uri.withAppendedpath(Phone.CONTENT_FILTER_URI,Uri.encode(constraint)),null);
while (cursor != null && cursor.movetoNext()) {
numberList.add(cursor.getString(cursor.getColumnIndexOrThrow(Phone.NUMBER)));
}
} finally {
if (cursor != null)
cursor.close();
}
return numberList;
}
项目:AndroidBase
文件:ContactsHelper.java
/**
* 得到手机通讯录联系人信息
*/
private void getPhoneContacts() {
ContentResolver resolver = mContext.getContentResolver();
//query查询,得到结果的游标
Cursor phoneCursor = resolver.query(Phone.CONTENT_URI,PHOnes_PROJECTION,null);
if (phoneCursor != null) {
while (phoneCursor.movetoNext()) {
//得到手机号码
String phoneNumber = phoneCursor.getString(PHOnes_NUMBER_INDEX);
//当手机号码为空的或者为空字段 跳过当前循环
if (TextUtils.isEmpty(phoneNumber)) {
continue;
}
//得到联系人名称
String contactName = phoneCursor.getString(PHOnes_disPLAY_NAME_INDEX);
ContactModel cb = new ContactModel();
cb.setContactName(contactName);
cb.setPhoneNumber(phoneNumber);
contactsList.add(cb);
}
phoneCursor.close();
}
}
项目:whereuat-android
文件:PhonebookUtils.java
/**
* Helper to retrieve a contact's information from the phone book activity
*
* @param data The Intent carrying the data of the phone book selection
* @param context Context to get content resolver from
* @return Contact object storing the name and phone number of the retrieved contact
*/
public static ContactUtils.Contact getContactFromPhonebook(Intent data,Context context) {
// Get the data from the Intent
Uri contact_data = data.getData();
// Query the Intent's data and extract the ID and name of the contact
String[] projection = {Phone.disPLAY_NAME,Phone.NUMBER};
String sel = String.format("%s = %s",Phone.TYPE,Phone.TYPE_MOBILE);
Cursor c = context.getContentResolver().query(contact_data,sel,null);
if (c.movetoFirst()) {
if (c.movetoFirst()) {
String name = c.getString(c.getColumnIndex(Phone.disPLAY_NAME));
String phone = convertToE164(c.getString(c.getColumnIndex(Phone.NUMBER)));
return new ContactUtils.Contact(name,phone);
}
c.close();
}
return new ContactUtils.Contact();
}
项目:zone-sdk
文件:ContactsHelper.java
/**
* 得到手机通讯录联系人信息
*/
private void getPhoneContacts() {
//query查询,得到结果的游标
Cursor phoneCursor = mResolver.query(Phone.CONTENT_URI,null);
if (phoneCursor != null) {
while (phoneCursor.movetoNext()) {
//得到手机号码
String phoneNumber = phoneCursor.getString(PHOnes_NUMBER_INDEX);
//当手机号码为空的或者为空字段 跳过当前循环
if (TextUtils.isEmpty(phoneNumber)) {
continue;
}
//得到联系人名称
String contactName = phoneCursor.getString(PHOnes_disPLAY_NAME_INDEX);
ContactModel cb = new ContactModel();
cb.setContactName(contactName);
cb.setPhoneNumber(phoneNumber);
contactsList.add(cb);
}
phoneCursor.close();
}
}
项目:phoneContact
文件:Utils.java
public static void addContact(String name,String number)
{
ContentValues values = new ContentValues();
//������RawContacts.CONTENT_URIִ��һ����ֵ���룬Ŀ���ǻ�ȡϵͳ���ص�rawContactId
Uri rawContactUri = m_context.getContentResolver().insert(RawContacts.CONTENT_URI,values);
long rawContactId = ContentUris.parseId(rawContactUri);
//��data�������������
values.clear();
values.put(Data.RAW_CONTACT_ID,rawContactId);
values.put(Data.MIMETYPE,Structuredname.CONTENT_ITEM_TYPE);//��������
values.put(Structuredname.GIVEN_NAME,name);
m_context.getContentResolver().insert(ContactsContract.Data.CONTENT_URI,values);
//��data�����绰����
values.clear();
values.put(Data.RAW_CONTACT_ID,rawContactId);
values.put(Data.MIMETYPE,Phone.CONTENT_ITEM_TYPE);
values.put(Phone.NUMBER,number);
values.put(Phone.TYPE,Phone.TYPE_MOBILE);
m_context.getContentResolver().insert(ContactsContract.Data.CONTENT_URI,values);
}
项目:phoneContact
文件:Utils.java
public static void changeContact(String name,String number,String ContactId)
{
Log.i("huahua",name);
ContentValues values = new ContentValues();
// ��������
values.put(Structuredname.GIVEN_NAME,name);
m_context.getContentResolver().update(ContactsContract.Data.CONTENT_URI,values,Data.RAW_CONTACT_ID + "=? and " + Data.MIMETYPE + "=?",new String[] { ContactId,Structuredname.CONTENT_ITEM_TYPE });
//���µ绰
values.clear();
values.put(ContactsContract.CommonDataKinds.Phone.NUMBER,number);
m_context.getContentResolver().update(ContactsContract.Data.CONTENT_URI,Phone.CONTENT_ITEM_TYPE});
}
项目:digits-android
文件:VCardBuilderTest.java
@Test
public void testAppendNameProperties_phone() {
final VCardBuilder builder = new VCardBuilder(VCardConfig.VCARD_TYPE_V30_GENERIC,VCardConfig.DEFAULT_EXPORT_CHARSET);
final ContentValues cv = new ContentValues();
final List<ContentValues> group = new ArrayList<>();
cv.put(ContactsContract.Data.MIMETYPE,Phone.CONTENT_ITEM_TYPE);
cv.put(Email.IS_PRIMARY,0);
cv.put(Email.DATA1,"(123) 123-4567");
group.add(cv);
final String card = builder.appendPhones(group,null).toString();
assertEquals(PHONE_CARD,card);
}
项目:TextSecureSMP
文件:ContactAccessor.java
private ContactData getContactData(Context context,number));
}
} finally {
if (numberCursor != null)
numberCursor.close();
}
return contactData;
}
项目:SDC
文件:ContactsListFragment.java
@Override
protected Void doInBackground(Long... ids) {
String[] projection = new String[] {Phone.disPLAY_NAME,Phone.LABEL};
long contactId = ids[0];
final Cursor phoneCursor = getActivity().getContentResolver().query(
Phone.CONTENT_URI,Data.CONTACT_ID + "=?",new String[]{String.valueOf(contactId)},null);
if(phoneCursor != null && phoneCursor.movetoFirst() && phoneCursor.getCount() == 1) {
final int contactNumberColumnIndex = phoneCursor.getColumnIndex(Phone.NUMBER);
mPhoneNumber = phoneCursor.getString(contactNumberColumnIndex);
int type = phoneCursor.getInt(phoneCursor.getColumnIndexOrThrow(Phone.TYPE));
mPhoneLabel = phoneCursor.getString(phoneCursor.getColumnIndex(Phone.LABEL));
mPhoneLabel = Phone.getTypeLabel(getResources(),mPhoneLabel).toString();
phoneCursor.close();
}
return null;
}
项目:Silence
文件:ContactAccessor.java
private ContactData getContactData(Context context,number));
}
} finally {
if (numberCursor != null)
numberCursor.close();
}
return contactData;
}
项目:Silence
文件:ContactAccessor.java
public List<String> getNumbersForThreadSearchFilter(Context context,String constraint) {
LinkedList<String> numberList = new LinkedList<>();
Cursor cursor = null;
try {
cursor = context.getContentResolver().query(Uri.withAppendedpath(Phone.CONTENT_FILTER_URI,null);
while (cursor != null && cursor.movetoNext()) {
numberList.add(cursor.getString(cursor.getColumnIndexOrThrow(Phone.NUMBER)));
}
} finally {
if (cursor != null)
cursor.close();
}
return numberList;
}
项目:NonViewUtils
文件:ContactsHelper.java
/**
* 得到手机通讯录联系人信息
*/
private void getPhoneContacts() {
ContentResolver resolver = mContext.getContentResolver();
//query查询,得到结果的游标
Cursor phoneCursor = resolver.query(Phone.CONTENT_URI,null);
if (phoneCursor != null) {
while (phoneCursor.movetoNext()) {
//得到手机号码
String phoneNumber = phoneCursor.getString(PHOnes_NUMBER_INDEX);
//当手机号码为空的或者为空字段 跳过当前循环
if (TextUtils.isEmpty(phoneNumber)) {
continue;
}
//得到联系人名称
String contactName = phoneCursor.getString(PHOnes_disPLAY_NAME_INDEX);
ContactModel cb = new ContactModel();
cb.setContactName(contactName);
cb.setPhoneNumber(phoneNumber);
contactsList.add(cb);
}
phoneCursor.close();
}
}
项目:Experimental-Fall-Detector-Android-App
文件:Contact.java
@Override
protected void onActivityResult(int requestCode,Intent data) {
super.onActivityResult(requestCode,resultCode,data);
if (RESULT_OK == resultCode) {
String selection = Phone.CONTACT_ID + "=?";
Uri result = data.getData();
String id = result.getLastPathSegment();
String[] arguments = new String[]{id};
ContentResolver resolver = getContentResolver();
Cursor cursor = resolver.query(Phone.CONTENT_URI,selection,arguments,null);
int index = cursor.getColumnIndex(Phone.DATA);
if (cursor.movetoFirst()) {
String phone = cursor.getString(index);
set(this,phone);
EditText edit = (EditText) findViewById(R.id.contact);
edit.setText(phone);
}
cursor.close();
}
}
项目:Interceptor
文件:EditFragment.java
@Override
public void onActivityResult(int requestCode,data);
if (requestCode == REQUEST_CODE) {
if (data != null) {
Uri result = data.getData();
String contractId = result.getLastPathSegment();
Cursor cursor = getActivity().getContentResolver().query(Phone.CONTENT_URI,new
String[]{
Phone.disPLAY_NAME,Phone.NUMBER},Phone.CONTACT_ID +
"=?",new String[]{contractId},null);
if (cursor != null && cursor.getCount() != 0) {
cursor.movetoFirst();
String phoneName = cursor.getString(cursor.getColumnIndexOrThrow(Phone
.disPLAY_NAME));
String phoneNum = cursor.getString(cursor.getColumnIndexOrThrow(Phone
.NUMBER));
mPhoneNumInput.setText(phoneNum);
mNote.setText(phoneName);
}
}
}
}
项目:laxture_lib_android
文件:ContactsUtil.java
public static HashMap<String,String> resolvePhoneNumber(Context context,Uri uri) {
HashMap<String,String> phoneList = new HashMap<String,String>();
Cursor cursor = context.getContentResolver().query(uri,PROJECTION_CONTACT,null);
if (cursor.movetoFirst()) {
String contactId = cursor.getString(cursor.getColumnIndexOrThrow(Contacts._ID));
String contactName = cursor.getString(cursor.getColumnIndexOrThrow(Contacts.disPLAY_NAME));
LLog.d("Selected Contact id/name :: %s/%s",contactId,contactName);
Cursor phoneCursor = context.getContentResolver().query(Phone.CONTENT_URI,PROJECTION_PHONE,Phone.CONTACT_ID+"="+contactId,null);
while (phoneCursor.movetoNext()) {
int type = phoneCursor.getInt(phoneCursor.getColumnIndexOrThrow(Phone.TYPE));
String typeLabel = Phone.getTypeLabel(context.getResources(),"UnkNow").toString();
phoneList.put(typeLabel,phoneCursor.getString(phoneCursor.getColumnIndexOrThrow(Phone.NUMBER)));
}
phoneCursor.close();
}
cursor.close();
return phoneList;
}
项目:mc_backup
文件:ContactService.java
private void initColumnNameConstantsMap() {
if (mColumnNameConstantsMap != null) {
return;
}
mColumnNameConstantsMap = new HashMap<String,String>();
mColumnNameConstantsMap.put("name",Structuredname.disPLAY_NAME);
mColumnNameConstantsMap.put("givenname",Structuredname.GIVEN_NAME);
mColumnNameConstantsMap.put("familyname",Structuredname.FAMILY_NAME);
mColumnNameConstantsMap.put("honorificprefix",Structuredname.PREFIX);
mColumnNameConstantsMap.put("honorificsuffix",Structuredname.SUFFIX);
mColumnNameConstantsMap.put("additionalname",CUSTOM_DATA_COLUMN);
mColumnNameConstantsMap.put("nickname",Nickname.NAME);
mColumnNameConstantsMap.put("adr",StructuredPostal.STREET);
mColumnNameConstantsMap.put("email",Email.ADDRESS);
mColumnNameConstantsMap.put("url",Website.URL);
mColumnNameConstantsMap.put("category",GroupMembership.GROUP_ROW_ID);
mColumnNameConstantsMap.put("tel",Phone.NUMBER);
mColumnNameConstantsMap.put("org",Organization.COMPANY);
mColumnNameConstantsMap.put("jobTitle",Organization.TITLE);
mColumnNameConstantsMap.put("note",Note.NOTE);
mColumnNameConstantsMap.put("impp",Im.DATA);
mColumnNameConstantsMap.put("sex",CUSTOM_DATA_COLUMN);
mColumnNameConstantsMap.put("genderidentity",CUSTOM_DATA_COLUMN);
mColumnNameConstantsMap.put("key",CUSTOM_DATA_COLUMN);
}
项目:mc_backup
文件:ContactService.java
private void initMimeTypeConstantsMap() {
if (mMimeTypeConstantsMap != null) {
return;
}
mMimeTypeConstantsMap = new HashMap<String,String>();
mMimeTypeConstantsMap.put("name",Structuredname.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("givenname",Structuredname.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("familyname",Structuredname.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("honorificprefix",Structuredname.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("honorificsuffix",Structuredname.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("additionalname",MIMETYPE_ADDITIONAL_NAME);
mMimeTypeConstantsMap.put("nickname",Nickname.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("email",Email.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("url",Website.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("category",GroupMembership.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("tel",Phone.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("org",Organization.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("jobTitle",Organization.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("note",Note.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("impp",Im.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("sex",MIMETYPE_SEX);
mMimeTypeConstantsMap.put("genderidentity",MIMETYPE_GENDER_IDENTITY);
mMimeTypeConstantsMap.put("key",MIMETYPE_KEY);
}
项目:ApkLauncher
文件:ExpandableList2.java
@Override
protected Cursor getChildrenCursor(Cursor groupCursor) {
// Given the group,we return a cursor for all the children within that group
// Return a cursor that points to this contact's phone numbers
Uri.Builder builder = Contacts.CONTENT_URI.buildUpon();
ContentUris.appendId(builder,groupCursor.getLong(GROUP_ID_COLUMN_INDEX));
builder.appendEncodedpath(Contacts.Data.CONTENT_DIRECTORY);
Uri phoneNumbersUri = builder.build();
mQueryHandler.startQuery(TOKEN_CHILD,groupCursor.getPosition(),phoneNumbersUri,PHONE_NUMBER_PROJECTION,Phone.MIMETYPE + "=?",new String[] { Phone.CONTENT_ITEM_TYPE },null);
return null;
}
项目:ApkLauncher
文件:ExpandableList2.java
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set up our adapter
mAdapter = new Myexpandablelistadapter(
this,android.R.layout.simple_expandable_list_item_1,new String[] { Contacts.disPLAY_NAME },// Name for group layouts
new int[] { android.R.id.text1 },new String[] { Phone.NUMBER },// Number for child layouts
new int[] { android.R.id.text1 });
setlistadapter(mAdapter);
mQueryHandler = new QueryHandler(this,mAdapter);
// Query for people
mQueryHandler.startQuery(TOKEN_GROUP,Contacts.CONTENT_URI,CONTACTS_PROJECTION,Contacts.HAS_PHONE_NUMBER + "=1",null);
}
项目:ApkLauncher
文件:List7.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list_7);
mPhone = (TextView) findViewById(R.id.phone);
getListView().setonItemSelectedListener(this);
// Get a cursor with all numbers.
// This query will only return contacts with phone numbers
Cursor c = getContentResolver().query(Phone.CONTENT_URI,PHONE_PROJECTION,Phone.NUMBER + " NOT NULL",null);
startManagingCursor(c);
listadapter adapter = new SimpleCursorAdapter(this,// Use a template that displays a text view
android.R.layout.simple_list_item_1,// Give the cursor to the list adapter
c,// Map the disPLAY_NAME column to...
new String[] {Phone.disPLAY_NAME},// The "text1" view defined in the XML template
new int[] {android.R.id.text1});
setlistadapter(adapter);
}
项目:ApkLauncher
文件:List7.java
public void onItemSelected(AdapterView<?> parent,View v,int position,long id) {
if (position >= 0) {
//Get current cursor
Cursor c = (Cursor) parent.getItemAtPosition(position);
int type = c.getInt(COLUMN_PHONE_TYPE);
String phone = c.getString(COLUMN_PHONE_NUMBER);
String label = null;
//Custom type? Then get the custom label
if (type == Phone.TYPE_CUSTOM) {
label = c.getString(COLUMN_PHONE_LABEL);
}
//Get the readable string
String numberType = (String) Phone.getTypeLabel(getResources(),label);
String text = numberType + ": " + phone;
mPhone.setText(text);
}
}
项目:ApiDemos
文件:ExpandableList2.java
@Override
protected Cursor getChildrenCursor(Cursor groupCursor) {
// Given the group,null);
return null;
}
项目:ApiDemos
文件:ExpandableList2.java
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set up our adapter
mAdapter = new Myexpandablelistadapter(
this,null);
}
项目:ApiDemos
文件:List7.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list_7);
mPhone = (TextView) findViewById(R.id.phone);
getListView().setonItemSelectedListener(this);
// Get a cursor with all numbers.
// This query will only return contacts with phone numbers
Cursor c = getContentResolver().query(Phone.CONTENT_URI,// The "text1" view defined in the XML template
new int[] {android.R.id.text1});
setlistadapter(adapter);
}
项目:ApiDemos
文件:List7.java
public void onItemSelected(AdapterView<?> parent,label);
String text = numberType + ": " + phone;
mPhone.setText(text);
}
}
项目:eDao
文件:OperateManageActivity.java
@Override
public void onClick(View view) {
operate_Manage_PopupWindow.dismiss();
switch (view.getId()) {
case R.id.popup_key_manage_textView_save:
Intent intent_save = new Intent(Intent.ACTION_INSERT);
intent_save.setType("vnd.android.cursor.dir/person");
intent_save.setType("vnd.android.cursor.dir/contact");
intent_save.setType("vnd.android.cursor.dir/raw_contact");
// 添加姓名
intent_save.putExtra(Insert.NAME,realName);
// 添加手机
intent_save.putExtra(Insert.PHONE_TYPE,Phone.TYPE_MOBILE);
intent_save.putExtra(Insert.PHONE,tel);
startActivity(intent_save);
break;
case R.id.popup_key_manage_textView_dial:
Intent intent_dial = new Intent(Intent.ACTION_CALL,Uri.parse("tel:" + tel));
startActivity(intent_dial);
break;
}
}
public void getPhoneNumbers(String id)
{
Log.d("getPhoneNumbers","looking data for contact id: " + id);
Cursor pCur = mContext.getContentResolver().query(Data.CONTENT_URI,new String[]
{ Data._ID,Phone.LABEL },Data.CONTACT_ID + "=?" + " AND "
+ Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",new String[]
{ String.valueOf(id) },null);
while (pCur.movetoNext())
{
String phoneNumber = pCur.getString(1);
String phoneType = pCur.getString(2);
String phoneLabel = pCur.getString(3);
if (isNumeric(phoneType))
{
Log.d("getPhoneNumbers","phoneNumber: " + phoneNumber + ",phoneType: " + phoneType + ",phoneLabel: " + phoneLabel);
}
}
pCur.close();
return;
}
项目:ntsync-android
文件:ContactOperations.java
/**
* Adds a phone number
*
* @param phone
* new phone number for the contact
* @param phoneType
* the type: cell,home,etc.
* @return instance of ContactOperations
*/
public ContactOperations addPhone(String phone,int phoneType,String label,boolean isPrimary,boolean isSuperPrimary) {
mValues.clear();
if (!TextUtils.isEmpty(phone)) {
mValues.put(Phone.NUMBER,phone);
mValues.put(Phone.TYPE,phoneType);
mValues.put(Phone.MIMETYPE,Phone.CONTENT_ITEM_TYPE);
if (!TextUtils.isEmpty(label)) {
mValues.put(Phone.LABEL,label);
}
if (isSuperPrimary) {
mValues.put(Email.IS_SUPER_PRIMARY,1);
}
if (isPrimary) {
mValues.put(Email.IS_PRIMARY,1);
}
addInsertOp();
}
return this;
}
项目:auto-contact-exchange
文件:AddContact.java
public String getPhoneNumber(long id) {
ArrayList<String> phones = new ArrayList<String>();
ContentResolver m = getContentResolver();
Cursor cursor = m.query(
CommonDataKinds.Phone.CONTENT_URI,CommonDataKinds.Phone.CONTACT_ID +" = ?",new String[]{""+id},null);
while (cursor.movetoNext())
{
phones.add(cursor.getString(cursor.getColumnIndex(CommonDataKinds.Phone.NUMBER)));
}
cursor.close();
return phones.get(0);
}
项目:launcherforblind
文件:PhoneBookActivity.java
@Override
protected ListEntry getListEntry(Cursor c) {
int phoneType = Integer.parseInt(c.getString(3));
String type = "";
if (phoneType == Phone.TYPE_HOME) {
type = getString(R.string.home);
} else if (phoneType == Phone.TYPE_MOBILE) {
type = getString(R.string.cell);
} else if (phoneType == Phone.TYPE_WORK) {
type = getString(R.string.work);
} else {
type = getString(R.string.other);
}
return new ContactListEntry(c.getString(0),c.getInt(1),c.getString(2));
}
项目:cInterphone
文件:Caller.java
boolean isExcludedType(Vector<Integer> vExTypesCode,String sNumber,Context oContext)
{
Uri contactRef = Uri.withAppendedpath(ContactsContract.CommonDataKinds.Phone.CONTENT_FILTER_URI,sNumber);
final String[] PHOnes_PROJECTION = new String[]
{
ContactsContract.CommonDataKinds.Phone.NUMBER,// 0
ContactsContract.CommonDataKinds.Phone.TYPE,// 1
};
Cursor phonesCursor = oContext.getContentResolver().query(contactRef,null);
if (phonesCursor != null)
{
while (phonesCursor.movetoNext())
{
final int type = phonesCursor.getInt(1);
if(vExTypesCode.contains(Integer.valueOf(type)))
return true;
}
phonesCursor.close();
}
return false;
}
项目:android_chat
文件:SearchContacts.java
@Override
protected String[] doInBackground(Void... params) {
String results = "";
Cursor c = act.getContentResolver().query(
Phone.CONTENT_URI,new String[]{Phone.NUMBER,Phone.disPLAY_NAME},null);
if (c != null) {
while(c.movetoNext()) {
String number = c.getString(c.getColumnIndex(Phone.NUMBER));
//String name = c.getString(c.getColumnIndex(Phone.disPLAY_NAME));
results += number + ",";
}
}
return results.split(",");
}
项目:Securecom-Messaging
文件:ContactAccessor.java
private ContactData getContactData(Context context,long id) {
ContactData contactData = new ContactData(id,displayName);
Cursor numberCursor = null;
try {
numberCursor = context.getContentResolver().query(Phone.CONTENT_URI,null);
while (numberCursor != null && numberCursor.movetoNext()) {
int type = numberCursor.getInt(numberCursor.getColumnIndexOrThrow(Phone.TYPE));
String label = numberCursor.getString(numberCursor.getColumnIndexOrThrow(Phone.LABEL));
String number = numberCursor.getString(numberCursor.getColumnIndexOrThrow(Phone.NUMBER));
String typeLabel = Phone.getTypeLabel(context.getResources(),label).toString();
contactData.numbers.add(new NumberData(typeLabel,number));
}
} finally {
if (numberCursor != null)
numberCursor.close();
}
return contactData;
}
项目:Securecom-Messaging
文件:ContactAccessor.java
public List<String> getNumbersForThreadSearchFilter(String constraint,ContentResolver contentResolver) {
LinkedList<String> numberList = new LinkedList<String>();
Cursor cursor = null;
try {
cursor = contentResolver.query(Uri.withAppendedpath(Phone.CONTENT_FILTER_URI,null);
while (cursor != null && cursor.movetoNext()) {
numberList.add(cursor.getString(cursor.getColumnIndexOrThrow(Phone.NUMBER)));
}
} finally {
if (cursor != null)
cursor.close();
}
return numberList;
}