私は Android で作業していますが、電話番号の連絡先の名前を見つける方法を知りたいです。
私はこれBroadcastReceiver
を持っています:
String phonenr=intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
この電話番号の連絡先名 (フルネーム - ファーストネーム + 姓) が必要です。
どうも!
私は Android で作業していますが、電話番号の連絡先の名前を見つける方法を知りたいです。
私はこれBroadcastReceiver
を持っています:
String phonenr=intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
この電話番号の連絡先名 (フルネーム - ファーストネーム + 姓) が必要です。
どうも!
Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME} .....)
以下の関数を次のように使用します。
Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode("your receive phone number"));
Cursor phones = getContentResolver().query(uri, new String[]{PhoneLookup.DISPLAY_NAME},null,null,null);
while (phones.moveToNext())
{
//it returns contact name
String name=phones.getString(phones.getColumnIndex(PhoneLookup.DISPLAY_NAME));
}
これを確認してください連絡先情報の取得
//query for the people in your address book
Cursor cursor = getContentResolver().query(People.CONTENT_URI, null, null, null,People.NAME + " ASC");
startManagingCursor(cursor);
//bind the name and the number fields
String[] columns = new String[] { People.NAME, People.NUMBER };
int[] to = new int[] { R.id.name_entry, R.id.number_entry };
SimpleContactAdapter mAdapter = new SimpleContactAdapter(this, R.layout.list_entry, cursor, columns, to);
this.setListAdapter(mAdapter);