2

Java Mail 外部ライブラリを使用して電子メールを送信するアプリを作成しています。Gmail に表示されているようなメール アドレスの候補をユーザーに表示するにはどうすればよいか、1 週間検索しました。

任意のヘルプが適用されます!

4

4 に答える 4

1

電子メールのリストを取得し、autocompleteTextViewを使用して入力時にそれらを表示します。

アダプターをtextBoxに設定します。

ArrayAdapter<String> namesAdapter = new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_dropdown_item_1line, names);
searchBox.setAdapter(namesAdapter);

searchBox.setOnItemClickListener(new OnItemClickListener() {

       public void onItemClick(AdapterView<?> arg0, View view, int position, long arg3) {
            String email = searchBox.getText().toString(); //or use the position to reference the email address you want.

        });
}
于 2012-06-23T13:48:53.470 に答える
1

私の知る限り、Gmailは提案にGmailアドレスブックを使用しています。あなたの提案のためにあなたはあなたの電話の連絡先を使うことができます、そしてあなたがそれらをあなたのGmailアドレスブックと同期させた場合、それらは連絡先でも利用可能です。

お役に立てれば!もっと具体的なことが必要な場合は、遠慮なくお問い合わせください。

于 2012-06-23T13:49:15.780 に答える
0

わかりました、少し掘り下げた後、ここに私が見つけたものがあります。オートコンプリート TextView に関する回答を取得し、それに以下を追加すると、探していたものが得られます。

Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI,null, null, null, null); 
    while (cursor.moveToNext()) { 
        String contactId = cursor.getString(cursor.getColumnIndex( 
                ContactsContract.Contacts._ID)); 
        String hasPhone = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER)); 
        if (Boolean.parseBoolean(hasPhone)) { 
            // You know it has a number so now query it like this
            Cursor phones = getContentResolver().query( ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = "+ contactId, null, null); 
            while (phones.moveToNext()) { 
                String phoneNumber = phones.getString(phones.getColumnIndex( ContactsContract.CommonDataKinds.Phone.NUMBER));                 
            } 
            phones.close(); 
        }

        Cursor emails = getContentResolver().query(ContactsContract.CommonDataKinds.Email.CONTENT_URI, null, ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = " + contactId, null, null); 
        while (emails.moveToNext()) { 
            // This would allow you get several email addresses 
            String emailAddress = emails.getString( 
                    emails.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));
        } 
        emails.close(); 
    }
    cursor.close();
于 2012-07-15T19:08:18.453 に答える
-1

"Smartr Contacts" http://smartrcontacts.com/は、Gmail と Android と iPhone 用の優れたアプリで、すべての連絡先を同期し、電子メール tel mob などをマージしてから、dbase から必要な電子メールを呼び出すことができます。

于 2012-07-04T07:51:15.217 に答える