gpt4 book ai didi

android - 在 Sony 设备上访问联系人电子邮件选择器

转载 作者:搜寻专家 更新时间:2023-11-01 08:45:16 28 4
gpt4 key购买 nike

我的应用程序使用手机内置的联系人选择器来允许用户选择电子邮件地址。我遇到的问题是这适用于我的 Nexus 5 (Lollipop) 和三星 (KitKat),但不适用于 Sony Experia Z1 (KitKat)。

我知道显然没有找到该 Activity ,但我找不到与索尼 Android 版本兼容的替代品,但这一定有可能吗?

这是我使用的代码 fragment :

Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.CommonDataKinds.Email.CONTENT_URI);
startActivityForResult(intent, 1);

下面是抛出的异常:

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.PICK dat=content://com.android.contacts/data/emails }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1632)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424)
at android.app.Activity.startActivityForResult(Activity.java:3424)
at android.app.Activity.startActivityForResult(Activity.java:3385)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:817)
at com.mtickner.runningmotivator.FriendListActivity.onOptionsItemSelected(FriendListActivity.java:73)
at android.app.Activity.onMenuItemSelected(Activity.java:2600)
at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:350)
at android.support.v7.app.ActionBarActivity.onMenuItemSelected(ActionBarActivity.java:155)
at android.support.v7.app.ActionBarActivityDelegate$1.onMenuItemSelected(ActionBarActivityDelegate.java:74)
at android.support.v7.app.ActionBarActivityDelegateBase.onMenuItemSelected(ActionBarActivityDelegateBase.java:556)
at android.support.v7.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:802)
at android.support.v7.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:153)
at android.support.v7.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:949)
at android.support.v7.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:939)
at android.support.v7.widget.ActionMenuView.invokeItem(ActionMenuView.java:596)
at android.support.v7.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:145)
at android.view.View.performClick(View.java:4569)
at android.view.View$PerformClick.run(View.java:18553)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:212)
at android.app.ActivityThread.main(ActivityThread.java:5135)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:877)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
at dalvik.system.NativeStart.main(Native Method)

编辑

此权限在 list 中:

<uses-permission android:name="android.permission.READ_CONTACTS" />

最佳答案

这是索尼手机的错误。您可以通过检查 intent 是否有可用 Activity 来确保应用不会崩溃。

Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.CommonDataKinds.Email.CONTENT_URI);

if(getPackageManager().resolveActivity(intent,0) != null)
{
startActivityForResult(intent, 1);
}

关于android - 在 Sony 设备上访问联系人电子邮件选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29035032/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com