0

enter image description here

I'm using the following code to load an audio file:

@Override
        public void onClick(View v) {
            Intent chooseFile;
            Intent intent;
            chooseFile = new Intent(Intent.ACTION_GET_CONTENT);
            chooseFile.setType("audio/*");
            intent = Intent.createChooser(chooseFile, "Choose a file");
            startActivityForResult(intent, ONE);

        }

This presents me with the above screen, but when the user uses an app like AndroidZip or any file managers the app crashes. How do I set "Select Music Track", which is native to android, as the default choice?

Chris Rohit Brendan
  • 893
  • 1
  • 9
  • 20

1 Answers1

0

You can try ndroid.content.Intent.ACTION_PICK action.

Besides, I don't exactly sure that "Select Music Track" activity is always present in every Android device.

You can also query the PackageManager on which packages handle the action you require and then based on the reply, you apply filtering and then fire the Intent you want with a Activity you want.

tasomaniac
  • 10,234
  • 6
  • 52
  • 84