开发者

Why does this code throw ActivityNotFoundException?

开发者 https://www.devze.com 2023-02-22 07:52 出处:网络
Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,Uri.encode(vc.cellphone)); Intent intent = new Intent();

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消