1

How do I create an activity/intent in the android manifest to fix the error below...

I am using https://github.com/MaginSoft/MFileChooser and I can see the picker and the file in the browser but I get 'android.content.ActivityNotFoundException' error

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 }

here is the java code from the plugin..

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);
}

Thanks for your help

Sergey Shustikov
  • 15,377
  • 12
  • 67
  • 119
user2570135
  • 2,669
  • 6
  • 50
  • 80

1 Answers1

2

The error is telling you that the device has no applications installed that are able to handle that particular implicit intent. You need to check whether an application is available before attempting to launch the intent like this:

// Verify that there are applications registered to handle this intent
// resolveActivity returns null if none are registered
if (intent.resolveActivity(getPackageManager()) != null) {
    startActivity(intent);
}
Abtin Gramian
  • 1,630
  • 14
  • 13
  • Thanks Abtin..Not sure what you mean by no application install to handle the intent. I am using the plugin and it should return the URL/filename. – user2570135 Oct 14 '16 at 00:17
  • What I mean is that the android phone or sim you are using has no application installed which can carry out the desired action (in this case to select a file). – Abtin Gramian Oct 14 '16 at 04:13
  • It looks like that plugin is no longer being actively developed as the last commit was 2 years ago. I would look for an alternative. – Abtin Gramian Oct 14 '16 at 04:20