微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

尝试在Cordova中启动Intent时出现android-ActivityNotFoundException

如何在Android清单中创建活动/意图以修复以下错误

我正在使用https://github.com/MaginSoft/MFileChooser,可以在浏览器中看到选择器和文件,但收到“ android.content.ActivityNotFoundException”错误

W/No activity found to handle file chooser intent.:
android.content.ActivityNotFoundException: No Activity found to handle
Intent { act=android.intent.action.GET_CONTENT cat=
android.intent.category.OPENABLE] typ=.doc,.docx,.rdf,.txt,.pdf,.odt }

这是插件中的Java代码.

public void chooseFile(CallbackContext callbackContext) {

        // type and title should be configurable
        Context context=this.cordova.getActivity().getApplicationContext();
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setClass(context,FileChooserActivity.class);

        Intent chooser = Intent.createChooser(intent, "Select File");
        cordova.startActivityForResult(this, chooser, PICK_FILE_REQUEST);

        PluginResult pluginResult = new PluginResult(PluginResult.Status.NO_RESULT);
        pluginResult.setKeepCallback(true);
        callback = callbackContext;
        callbackContext.sendpluginResult(pluginResult);
}

谢谢你的帮助

解决方法:

错误告诉您该设备未安装能够处理该特定隐式意图的应用程序.尝试像这样启动意图之前,您需要检查应用程序是否可用:

// Verify that there are applications registered to handle this intent
// resolveActivity returns null if none are registered
if (intent.resolveActivity(getPackageManager()) != null) {
    startActivity(intent);
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐