Why does this code throw ActivityNotFoundException?
Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,Uri.encode(vc.cellphone));
Intent intent = new Intent();
intent.setAction(ContactsContract.Intents.SHOW_OR_CREATE_CONTACT);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(lookupUri);
getApplicationContext().startActivity(intent);
The contact with cell phone number the same as vc.cellphone开发者_如何学运维
is in the contacts.
I'm wondering if your Uri
is the problem. What about trying this:
Intent intent = new Intent(ContactsContract.Intents.SHOW_OR_CREATE_CONTACT);
intent.setData(Uri.fromParts("tel", vc.cellphone, null));
startActivity(intent);
Edit - I tried this in the emulator and it works, say, if vc.cellphone
is "1234567890"
.
Do you have additional code involved with this intent?
精彩评论