【dayu短信插件源码】【外汇跟单RSSA源码】【需求量大的源码】android 通讯录 源码

2025-01-20 04:33:04 来源:缠论三类买卖点主图源码 分类:娱乐

1.android ͨѶ¼ Դ?讯录?

android 通讯录 源码

android ͨѶ¼ Դ??

       1. Modify the `getTelClick()` method:

        - Change the method name from `getTelClick` to `onGetTelClick` for better readability and adherence to naming conventions.

        - Ensure that the method signature is correct and that it is properly calling the new method.

       2. Modify the Toast breadcrumb提示:

        - Remove the unnecessary string concatenation within the Toast message.

        - Use string resources for the Toast message to improve localization support.

       3. Modify the method for获取联系人名字:

        - Correct the column index for the contact's name to match the correct field from the ContactsContract.

       4. Adjust the location slightly:

        - Ensure that the code for finding the contact's phone number is inside the correct `if` block to avoid unnecessary queries.

       Here is the modified section of the code:

       ```java

       // ... (previous code)

       @Override

       protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_phone_name);

        et = (EditText) this.findViewById(R.id.mobile);

       }

       public void onGetTelClick(View view) {

        String name = et.getText().toString().trim();

        getContactNumber(name);

       }

       /

**

        * 通过输入的姓名获取电话号码

        */

       public void getContactNumber(String name) {

        // 使用ContentResolver查找联系人数据

        Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);

        // 遍历查询结果,找到所需号码

        while (cursor.moveToNext()) {

        // 获取联系人ID

        String contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));

        // 获取联系人的源码dayu短信插件源码名字

        String contactName = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));

        if (name.equals(contactName)) {

        // 使用ContentResolver查找联系人的电话号码

        Cursor phone = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", new String[]{ contactId}, null);

        if (phone.moveToNext()) {

        String phoneNumber = phone.getString(phone.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));

        Toast.makeText(this, phoneNumber, Toast.LENGTH_SHORT).show(); // Use string resource for the message

        Log.d(TAG, "电话:" + phoneNumber);

        break;

        }

        }

        }

       }

       ```

       Ensure that you have defined a string resource for the Toast message in your `res/values/strings.xml` file, like this:

       ```xml

        电话号码:%1$s

       ```

       And use it in the Toast.makeText method as shown above.

更多资讯请点击:娱乐

热门资讯

mblock 源码

2025-01-20 03:521136人浏览

中科源码_中科源码熊

2025-01-20 03:48776人浏览

源码hbase

2025-01-20 03:082824人浏览

strstr源码

2025-01-20 01:491944人浏览

推荐资讯

受河流侵蝕潛在影響 珠峰每年輕微「增高」

喜瑪拉雅山珠穆朗瑪峰是全球最高山峰,施普林格·自然旗下專業學術期刊《自然-地球科學》北京時間9月30日晚上在線發表一篇中國及多國科學家合作發表的最新論文指出,在河流侵蝕的潛在影響下,導致

源码ffmpeg

1.理解ffmpeg2.FFmpeg源码分析: AVStream码流3.FFmpeg交叉编译、脚本参数配置4.FFmpeg源码分析:视频滤镜介绍(上)5.FFmpeg开发笔记十二)Linux环境给FF

rang源码

1.rangԴ??2.请教关于querylist解析错误的问题3.netfilter/iptables模块编译及应用rangԴ?? keep_words=['and','as','assert',