ActivityNotFoundException при попытке запустить Intent в Cordova

Как создать действие / намерение в манифесте 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);
}

Спасибо за вашу помощь

1 ответ

Ошибка говорит о том, что на устройстве не установлены приложения, способные справиться с этим конкретным неявным намерением. Вам нужно проверить, доступно ли приложение, прежде чем пытаться запустить намерение следующим образом:

// Verify that there are applications registered to handle this intent
// resolveActivity returns null if none are registered
if (intent.resolveActivity(getPackageManager()) != null) {
    startActivity(intent);
}
Другие вопросы по тегам