0

I am trying to use spacebowboy's NoNonsense FilePicker, but am having problems receiving the Uri. The intent call works just fine, but the receiving code is copied straight from the repository and I can't see how it's anything I could be doing wrong. The receiving code is as:

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    switch(requestCode) {
        case (FILE_CODE) : { Log.v("myapplication","recieved result from file chooser");
            if (resultCode == Activity.RESULT_OK) {
                Log.v("myapplication","result ok");
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    Log.v("myapplication","This is as far as we get.");
                    ClipData clip = data.getClipData();

                    if (clip != null) { // Clip is always null, but why?
                        for (int i = 0; i < clip.getItemCount(); i++) {
                            Uri uri = clip.getItemAt(i).getUri();
                            // Do something with the URI
                            Log.v("myapplication","Success!");
                        }
                    }
                    // For Ice Cream Sandwich
                } else {
                    ArrayList<String> paths = data.getStringArrayListExtra
                            (FilePickerActivity.EXTRA_PATHS);

                    Log.v("myapplication","Using a newer version, so this code is never used.");

                    if (paths != null) {
                        for (String path: paths) {
                            Uri uri = Uri.parse(path);
                            // Do something with the URI
                        }
                    }
                }
            }
        }
    }
}

Alternately, if there are suggestions of other (better, functional, hopefully easy) methods I could be using to pick files, that would also be great.

Serelesis
  • 1
  • 2

0 Answers0