为什么我的编辑工作接触? [英] Why isn't my edit contact working?

查看:136
本文介绍了为什么我的编辑工作接触?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我显示联系人列表,并有上下文菜单调用的意图编辑联系。在一些接触它工作正常,但对他人的编辑联系人的活动是空白。任何想法?

下面是光标...

 投影=新String[]{ContactsContract.CommonDataKinds.Phone.NUMBER,ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,ContactsContract.CommonDataKinds.Phone._ID};
 URI = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
 光标= getActivity()getContentResolver()查询(URI,投影,NULL,NULL,ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME +ASC)。

下面是从我CursorAdapter.getView(在code)...

<$p$p><$c$c>textView.setText(cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)) ;

这是从code我onContextItemSelected ...

  cursor.moveToPosition(位置);
串idContact = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
意图I =新意图(Intent.ACTION_EDIT);
i.setData(Uri.parse(ContactsContract.Contacts.CONTENT_LOOKUP_URI +/+ idContact));
parent.startActivity(ⅰ);

我检查logcat的和可以看到

  I / ActivityManager(102):启动活动:意向{行动= android.intent.action.EDIT DAT =内容://com.android.contacts/contacts/lookup/23356 CMP = com.android.htccontacts / .ui.EditContactActivity}

但没有错误messges


解决方案

试试这个:

 开放的URI = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
光标光标= this.getContentResolver()查询(URI,NULL,NULL,NULL,ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME +ASC)。
长idContact = cursor.getLong(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.CONTACT_ID));

然后

 意向书I =新意图(Intent.ACTION_EDIT);
乌里contactUri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI,idContact);
i.setData(contactUri);

I'm displaying a list of Contacts, and have a context menu to Edit Contact by calling an intent. On some contacts it works fine, but on others the Edit Contact activity is blank. Any ideas?

Here is the cursor...

 projection = new String[]{ContactsContract.CommonDataKinds.Phone.NUMBER,ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,ContactsContract.CommonDataKinds.Phone._ID};   
 uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
 cursor = getActivity().getContentResolver().query(uri, projection, null, null,    ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + " ASC");

Here is the code from my CursorAdapter.getView() ...

textView.setText(cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)) ;

And here is the code from my onContextItemSelected...

cursor.moveToPosition(position);
String idContact = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
Intent i = new Intent(Intent.ACTION_EDIT);
i.setData(Uri.parse(ContactsContract.Contacts.CONTENT_LOOKUP_URI + "/" + idContact));
parent.startActivity(i);

I've checked logcat and can see

I/ActivityManager(  102): Starting activity: Intent { act=android.intent.action.EDIT dat=content://com.android.contacts/contacts/lookup/23356 cmp=com.android.htccontacts/.ui.EditContactActivity }

but no error messges

解决方案

Try this:

Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
Cursor cursor = this.getContentResolver().query(uri, null, null, null, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + " ASC");
long idContact = cursor.getLong(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.CONTACT_ID));

then

Intent i = new Intent(Intent.ACTION_EDIT);
Uri contactUri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, idContact); 
i.setData(contactUri);

这篇关于为什么我的编辑工作接触?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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