1

私は Android で作業していますが、電話番号の連絡先の名前を見つける方法を知りたいです。

私はこれBroadcastReceiverを持っています:

String phonenr=intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);

この電話番号の連絡先名 (フルネーム - ファーストネーム + 姓) が必要です。

どうも!

4

2 に答える 2

1

このリンクを試すことができます

 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));
        }
于 2012-04-23T11:51:34.280 に答える
0

これを確認してください連絡先情報の取得

 //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);
于 2012-04-23T11:59:33.067 に答える