【数码宝贝源码什么时候开服】【pc打电话源码】【macd最佳买入源码】android通讯录源码

2025-01-31 02:50:47 来源:linux源码下载 分类:百科

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));

        // 获取联系人的源码数码宝贝源码什么时候开服名字

        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.

更多资讯请点击:百科

热门资讯

paysys源码

2025-01-31 01:322390人浏览

todos源码

2025-01-31 00:472595人浏览

hudi 源码

2025-01-31 00:401571人浏览

rlusb源码

2025-01-31 00:071896人浏览

推荐资讯

北京开展年货市场专项检查

春节将至,北京市各级市场监管部门对年货市场和米面粮油、蔬菜、酒类等节日热销商品加大检查力度,结合节日消费特点,强化节日食品的快速检测和监督抽检,全面落实“菜篮子”负责制,助力广大市民过上安全、祥和的春

蔚蓝源码_蔚蓝 代码

1.冉宏宇人生经历2.装模作样是什么动物3.**出门是什么动物冉宏宇人生经历 冉宏宇年考入中国科技大学,主修空气动力学。那时科大生活很简单,就是读书、考试、申请出国。他回忆道:“那时去科大就是奔出

dubbonacos源码

1.如何成为一个java架构师?2.深度剖析:Dubbo使用Nacos注册中心的坑如何成为一个java架构师? 在探讨如何成为Java架构师的过程中,关键问题在于实践与理论的结合。许多Java开发