storage-chooser
storage-chooser copied to clipboard
StringIndexOutOfBoundsException at com.codekidlabs.storagechooser.fragments.SecondaryChooserFragment.populateList(SecondaryChooserFragment.java:623)
https://github.com/KYHSGeekCode/Android-Disassembler/issues/47
Well, it is said that StringIndexOutOfBoundsException is occuring from your code.
My code is here like this.
private void showFileChooser()
{
requestAppPermissions(this);
//SharedPreferences sharedPreferences = null;
settingPath=getSharedPreferences("path",MODE_PRIVATE);
String prepath=settingPath.getString(DiskUtil.SC_PREFERENCE_KEY,"/storage/emulated/0/");
File tmp=new File(prepath);
if(tmp.isFile())
{
tmp=tmp.getParentFile();
prepath=tmp.getAbsolutePath();
}
SharedPreferences spPicker=getSharedPreferences(SETTINGKEY,MODE_PRIVATE);
int picker=spPicker.getInt("Picker",0);
switch(picker)
{
case 0:
StorageChooser chooser = new StorageChooser.Builder()
.withActivity(MainActivity.this)
.withFragmentManager(getFragmentManager())
.withMemoryBar(true)
.allowCustomPath(true)
.setType(StorageChooser.FILE_PICKER)
.actionSave(true)
//.withPreference(settingPath)
// .withPredefinedPath(prepath)
.shouldResumeSession(true)
.showHidden(true)
.build();
// Show dialog whenever you want by
//chooser.getsConfig().setPrimaryPath(prepath);
chooser.show();
// get path that the user has chosen
chooser.setOnSelectListener(new StorageChooser.OnSelectListener() {
@Override
public void onSelect(String path) {
SharedPreferences.Editor edi=settingPath.edit();
edi.putString(DiskUtil.SC_PREFERENCE_KEY,path);
edi.apply();
disableEnableControls(false,llmainLinearLayoutSetupRaw);
OnChoosePath(path);
//Log.e("SELECTED_PATH", path);
}
});
break;
case 1:
Intent i=new Intent(this, com.kyhsgeekcode.rootpicker.FileSelectorActivity.class);
startActivityForResult(i, REQUEST_SELECT_FILE);
break;
} //
}
Hi, thanks for letting me know. I have got this weird bug sometimes but I couldn't spot the error as the next time it would work. The dev-3.0 branch is now rewritten in Kotlin and has a fresh codebase so I hope this won't come in the next release as well.
I'm not closing this issue until 3.0.
+1 My users are reporting this issue too
Until this is fixed, should I just be catching the StringIndexOutOfBoundsException and retrying?
Fixed in my fork branch, basicly what i do is if i got an exception i set the selected folder to default music folder (at least app doesnt crash because of this)
https://github.com/muzzikapp/storage-chooser
@muzzikapp thanks for this. Was there any reason why you weren't able to create PR?
@muzzikapp thanks for this. Was there any reason why you weren't able to create PR?
@codekidX you are welcome. I didn't create a PR just because my fix is just intended to be used in my app. But if you think it is a good way of handling this error, i can create a PR as well.