需求:
在自己的程序中调用联系人列表,然后选择某个联系人,返回该联系人的Uri。
官方文档上说的是:
action / data
ACTION_VIEW content://contacts/ -- Display a list of people, which the user can browse through.
但是按照这个写法会报错:
04-02 02:00:08.246: ERROR/DatabaseUtils(92): java.lang.IllegalArgumentException: Unknown URL
04-02 02:00:16.626: ERROR/AndroidRuntime(255): android.content.ActivityNotFoundException: No Activity found to handle Intent { action=android.intent.action.PICK data=content://contacts }
后来发现正确写法是这样的:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_PICK);
intent.setData(Contacts.People.CONTENT_URI);
startActivity(intent);
startActivityForResult(intent, 0);
在自己的程序中调用联系人列表,然后选择某个联系人,返回该联系人的Uri。
官方文档上说的是:
action / data
ACTION_VIEW content://contacts/ -- Display a list of people, which the user can browse through.
但是按照这个写法会报错:
04-02 02:00:08.246: ERROR/DatabaseUtils(92): java.lang.IllegalArgumentException: Unknown URL
04-02 02:00:16.626: ERROR/AndroidRuntime(255): android.content.ActivityNotFoundException: No Activity found to handle Intent { action=android.intent.action.PICK data=content://contacts }
后来发现正确写法是这样的:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_PICK);
intent.setData(Contacts.People.CONTENT_URI);
startActivity(intent);
startActivityForResult(intent, 0);