Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fragment use: You must provide EXTRA_CONFIG when starting the DirectoryChooserActivity #80

Open
Hofferic opened this issue Feb 25, 2016 · 4 comments

Comments

@Hofferic
Copy link

I am using the dirchooser in Fragment mode and every so often I get crash reports originating form the IllegalArgumentException "You must provide EXTRA_CONFIG when starting the DirectoryChooserActivity". That exception is only thrown in the Activity version and I cannot for the life of me figure out how that gets involved in he process. The crash reports do tend to come from devices with tiny screens like the Defy Mini XT320 on older Android versions, but I am stumped how to solve this.

My calling code looks like this:

public void setDownloadFolder(@SuppressWarnings("UnusedParameters") @Nullable View view){
        if(!Globals.PERMISSION_STORAGE){
            // this just makes sure the permission is requested and this method
            // called again with the same parameters if granted
            requestStoragePermissions(this, "setDownloadFolder", new Object[]{null});
            return;
        }

        final DirectoryChooserConfig config = DirectoryChooserConfig.builder()
                .newDirectoryName("EBooks")
                .initialDirectory(settings.getString(Globals.DOWNLOAD_DIR,
                        Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath()))
                .allowNewDirectoryNameModification(true)
                .allowReadOnlyDirectory(false)
                .build();
        mDialog = DirectoryChooserFragment.newInstance(config);
        mDialog.show(getFragmentManager(), null);
}

EDIT: I am using version 3.2 of the library

@passy
Copy link
Owner

passy commented Feb 28, 2016

Hey @Hofferic,

thanks for the bug report. I'm a bit confused. Does this happen when using the chooser as a fragment or an activity? Since the error message can only be thrown from the activity I assume it's the latter, but your code is for a fragment. Can you clarify this for me?

@Hofferic
Copy link
Author

That is exactly what confuses me, I only use the above method and a nearly exact copy with slightly different permission handling in the onboarding activity. I only ever use the fragment and cannot explain for the life of me how the activity comes into this. Here is the second method I use to call the library:

private void setDownloadFolder(){
        if(!Globals.PERMISSION_STORAGE){
            Hacks.coerceFullWidth(
                    Snackbar.make(findViewById(R.id.oobe_gestureOverlayView), R.string.snackbar_permission_storage, Snackbar.LENGTH_LONG)
            ).setAction(R.string.snackbar_permission_action, new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                    intent.setData(android.net.Uri.parse("package:com.hoffmann.eric.calibrebox"));
                    startActivity(intent);
                }
            }).show();
            return;
        }

        final DirectoryChooserConfig config = DirectoryChooserConfig.builder()
                .newDirectoryName("EBooks")
                .initialDirectory(getSharedPreferences(Globals.SETTINGS_NAME, MODE_PRIVATE).getString(Globals.DOWNLOAD_DIR,
                        Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath()))
                .allowNewDirectoryNameModification(true)
                .allowReadOnlyDirectory(false)
                .build();
        mDialog = DirectoryChooserFragment.newInstance(config);
        mDialog.show(getFragmentManager(), null);
    }

And here is the crash trace (as it is in onCreate I would guess it happens during configuration changes, as the dialog is only opened after the user clicks a button. But rotating while the fragment is open did not reproduce the issue on any of my test devices)

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hoffmann.eric.calibrebox/net.rdrei.android.dirchooser.DirectoryChooserActivity}: java.lang.IllegalArgumentException: You must provide EXTRA_CONFIG when starting the DirectoryChooserActivity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by java.lang.IllegalArgumentException: You must provide EXTRA_CONFIG when starting the DirectoryChooserActivity.
at net.rdrei.android.dirchooser.DirectoryChooserActivity.onCreate(DirectoryChooserActivity.java:32)
at android.app.Activity.performCreate(Activity.java:5133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
at dalvik.system.NativeStart.main(NativeStart.java)

@Hofferic
Copy link
Author

I just had an Idea where the Activity version is referenced - In the Manifest!

<!-- file picker -->
<activity android:name="net.rdrei.android.dirchooser.DirectoryChooserActivity" />

Not sure if that contributes to this mysterious crash though :/

@nghelam2008
Copy link

nghelam2008 commented Jul 12, 2016

same problem! However, I use in Activity with your code so it work well. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants