public void ShowMultipleMIME(final BA ba, String[] MimeTypes, String Title) {
if (eventName == null)
throw new RuntimeException("ContentChooser not initialized.");
Intent in = new Intent(Intent.ACTION_GET_CONTENT);
in.setType("*/*");
in.putExtra(Intent.EXTRA_MIME_TYPES, MimeTypes);
in.addCategory(Intent.CATEGORY_OPENABLE);
in = Intent.createChooser(in, Title);
ion = new IOnActivityResult() {
@Override
public void ResultArrived(int resultCode, Intent intent) {
String Dir = null, File = null;
if (resultCode == Activity.RESULT_OK && intent != null && intent.getData() != null) {
try {
Uri uri = intent.getData();
String scheme = uri.getScheme();
if (ContentResolver.SCHEME_FILE.equals(scheme)) {
Dir = "";
File = uri.getPath();
}
else if (ContentResolver.SCHEME_CONTENT.equals(scheme)) {
Dir = anywheresoftware.b4a.objects.streams.File.ContentDir;
File = uri.toString();
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
ion = null;
if (Dir != null && File != null) {
ba.raiseEvent(ContentChooser.this, eventName + "_result", true, Dir, File);
}
else {
ba.raiseEvent(ContentChooser.this, eventName + "_result", false, "", "");
}
}
};
ba.startActivityForResult(ion, in);
}