未能提供结果ResultInfo {谁= NULL,请求= 1,结果= -1,数据= {意向DAT =内容://com.android.contacts/contacts/lookup...}} [英] Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=content://com.android.contacts/contacts/lookup…}}

查看:172
本文介绍了未能提供结果ResultInfo {谁= NULL,请求= 1,结果= -1,数据= {意向DAT =内容://com.android.contacts/contacts/lookup...}}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出错我选择从联系人列表中的联系人。
从你任何帮助将是不错...
这里是code从接触接收号码,显示编辑文本视图是:

私人无效importContact(){

 意图importContactIntent =新意图(Intent.ACTION_PICK);
    importContactIntent.setType(ContactsContract.Contacts.CONTENT_TYPE);
    startActivityForResult(importContactIntent,PICK_CONTACT);}@覆盖
公共无效的onActivityResult(INT REQ code,INT结果code,意图数据){
    super.onActivityResult(REQ code,结果code,数据);
    开关(REQ code){
    案例(PICK_CONTACT):        如果(结果code == Activity.RESULT_OK){
            //乌里联络资料= data.getData();
            字符串ID = cursor.getString(光标
                    .getColumnIndex(ContactsContract.Contacts._ID));
            字符串名称=光标
                    .getString(光标
                            .getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));            如果(整数
                    .parseInt(cursor.getString(光标
                            .getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER)))> 0){
                //的System.out.println(名称:+姓名+,ID:+身份证);                //现在使用查询该particulat接触的所有号码
                // CONTACT_ID
                光标pCur = getContentResolver()查询(
                        ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
                        空值,
                        ContactsContract.CommonDataKinds.Phone.CONTACT_ID
                                +=?,新的String [] {ID},NULL);
                而(pCur.moveToNext()){
                    //你可以存储手机放在数组列表
                    destinationPhoneNumber = pCur
                            .getString(pCur
                                    .getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
                    //
                    enterPhoneNumber.setText(destinationPhoneNumber);
                    Toast.makeText(这一点,
                            名称+有号+ destinationPhoneNumber,
                            Toast.LENGTH_LONG).show();                    cursor.close();
                }
            }
        }

下面是日志猫错误:

 致命异常:主要
 了java.lang.RuntimeException:不提供结果ResultInfo {谁= NULL,请求= 1,结果= -1,数据= {意向DAT =内容://com.android.contacts/contacts/lookup/0i473.3217i217333/217328(有群众演员)}}到活动{np.com.rsubedi.balancetransfer / np.com.rsubedi.balancetransfer.BTmain}:显示java.lang.NullPointerException
    在android.app.ActivityThread.deliverResults(ActivityThread.java:3515)
    在android.app.ActivityThread.handleSendResult(ActivityThread.java:3557)
    在android.app.ActivityThread.access $ 2800(ActivityThread.java:125)
    在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:2063)
    在android.os.Handler.dispatchMessage(Handler.java:99)
    在android.os.Looper.loop(Looper.java:123)
    在android.app.ActivityThread.main(ActivityThread.java:4627)
    在java.lang.reflect.Method.invokeNative(本机方法)
    在java.lang.reflect.Method.invoke(Method.java:521)
    在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:858)
    在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
    在dalvik.system.NativeStart.main(本机方法)
 显示java.lang.NullPointerException:产生的原因
    在np.com.rsubedi.balancetransfer.BTmain.onActivityResult(BTmain.java:220)
    在android.app.Activity.dispatchActivityResult(Activity.java:3890)
    在android.app.ActivityThread.deliverResults(ActivityThread.java:3511)
    ... 11更多


解决方案

您必须先查询联系人数据库是这样的:

  ContentResolver的resolvr = getContentResolver();
光标光标= resolvr.query(ContactsContract.Contacts.CONTENT_URI,NULL,NULL,NULL,NULL);

该结果是光标

Error while i choose a contact from the contact list . Any help from you will be nice ... Here is the code for receiving number from contact and showing it in edit text view :

private void importContact() {

    Intent importContactIntent = new Intent(Intent.ACTION_PICK);
    importContactIntent.setType(ContactsContract.Contacts.CONTENT_TYPE);
    startActivityForResult(importContactIntent, PICK_CONTACT);

}

@Override
public void onActivityResult(int reqCode, int resultCode, Intent data) {
    super.onActivityResult(reqCode, resultCode, data);
    switch (reqCode) {
    case (PICK_CONTACT):

        if (resultCode == Activity.RESULT_OK) {
            // Uri contactData = data.getData();
            String id = cursor.getString(cursor
                    .getColumnIndex(ContactsContract.Contacts._ID));
            String name = cursor
                    .getString(cursor
                            .getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));

            if (Integer
                    .parseInt(cursor.getString(cursor
                            .getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) {
                // System.out.println("name : " + name + ", ID : " + id);

                // NOW query all numbers of that particulat contact using
                // contact_Id
                Cursor pCur = getContentResolver().query(
                        ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
                        null,
                        ContactsContract.CommonDataKinds.Phone.CONTACT_ID
                                + " = ?", new String[] { id }, null);
                while (pCur.moveToNext()) {
                    // you can store phone in a arrayList
                    destinationPhoneNumber = pCur
                            .getString(pCur
                                    .getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
                    //
                    enterPhoneNumber.setText(destinationPhoneNumber);
                    Toast.makeText(this,
                            name + " has number " + destinationPhoneNumber,
                            Toast.LENGTH_LONG).show();

                    cursor.close();
                }
            }
        }

Here is the log cat error :

FATAL EXCEPTION: main
 java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=content://com.android.contacts/contacts/lookup/0i473.3217i217333/217328 (has extras) }} to activity {np.com.rsubedi.balancetransfer/np.com.rsubedi.balancetransfer.BTmain}: java.lang.NullPointerException
    at android.app.ActivityThread.deliverResults(ActivityThread.java:3515)
    at android.app.ActivityThread.handleSendResult(ActivityThread.java:3557)
    at android.app.ActivityThread.access$2800(ActivityThread.java:125)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2063)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:123)
    at android.app.ActivityThread.main(ActivityThread.java:4627)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
    at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.NullPointerException
    at np.com.rsubedi.balancetransfer.BTmain.onActivityResult(BTmain.java:220)
    at android.app.Activity.dispatchActivityResult(Activity.java:3890)
    at android.app.ActivityThread.deliverResults(ActivityThread.java:3511)
    ... 11 more

解决方案

You have to first query the Contacts DB like this:

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

The resultSet is in cursor.

这篇关于未能提供结果ResultInfo {谁= NULL,请求= 1,结果= -1,数据= {意向DAT =内容://com.android.contacts/contacts/lookup...}}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆