GithubHelp home page GithubHelp logo

ipaulpro / afilechooser Goto Github PK

View Code? Open in Web Editor NEW
1.8K 116.0 851.0 5.26 MB

[DEPRECATED] Android library that provides a file explorer to let users select files on external storage.

License: Apache License 2.0

Java 100.00%

afilechooser's Introduction

aFileChooser - Android File Chooser

aFileChooser is an Android Library Project that simplifies the process of presenting a file chooser on Android 2.1+.

Intents provide the ability to hook into third-party app components for content selection. This works well for media files, but if you want users to be able to select any file, they must have an existing "file explorer" app installed. Because many Android devices don't have stock File Explorers, the developer must often instruct the user to install one, or build one, themselves. aFileChooser solves this issue.

Features:

  • Full file explorer
  • Simplify GET_CONTENT Intent creation
  • Hooks into Storage Access Framework
  • Determine MIME data types
  • Follows Android conventions (Fragments, Loaders, Intents, etc.)
  • Supports API 7+

screenshot-1 screenshot-2

Setup

Add aFileChooser to your project as an Android Library Project.

Add FileChooserActivity to your project's AndroidManifest.xml file with a fully-qualified name. The label and icon set here will be shown in the "Intent Chooser" dialog.

Important FileChooserActivity must have android:exported="true" and have the <intent-filter> set as follows:

<activity
    android:name="com.ipaulpro.afilechooser.FileChooserActivity"
    android:icon="@drawable/ic_chooser"
	android:enabled="@bool/use_activity"
    android:exported="true"
    android:label="@string/choose_file" >
    <intent-filter>
        <action android:name="android.intent.action.GET_CONTENT" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.OPENABLE" />

        <data android:mimeType="*/*" />
    </intent-filter>
</activity>

If you want to use the Storage Access Framework (API 19+), include Ian Lake's LocalStorageProvider (included in this library) in your <application>:

<provider
    android:name="com.ianhanniballake.localstorage.LocalStorageProvider"
    android:authorities="com.ianhanniballake.localstorage.documents"
	android:enabled="@bool/use_provider"
    android:exported="true"
    android:grantUriPermissions="true"
    android:permission="android.permission.MANAGE_DOCUMENTS" >
        <intent-filter>
            <action android:name="android.content.action.DOCUMENTS_PROVIDER" />
        </intent-filter>
</provider>

Note that like a ContentProvider, the DocumentProvider authority must be unique. You should change com.ianhanniballake.localstorage.documents in your Manifest, as well as the LocalStorageProvider.AUTHORITY field.

Using FileChooserActivity and LocalStorageProvider together are redundant if you're only trying to insure your user has access to local storage. If this is the case, you should enable/disable based on the API level (above: @bool/use_provider and @bool/use_activity). See the aFileChooserExample project for their values.

Usage

Use startActivityForResult(Intent, int) to launch FileChooserActivity directly. FileChooserActivity returns the Uri of the file selected as the Intent data in onActivityResult(int, int, Intent). Alternatively, you can use the helper method FileUtils.createGetContentIntent() to construct an ACTION_GET_CONTENT Intent that will show an "Intent Chooser" dialog on pre Kit-Kat devices, and the "Documents UI" otherwise. E.g.:

private static final int REQUEST_CHOOSER = 1234;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Create the ACTION_GET_CONTENT Intent
    Intent getContentIntent = FileUtils.createGetContentIntent();
	
    Intent intent = Intent.createChooser(getContentIntent, "Select a file");
    startActivityForResult(intent, REQUEST_CHOOSER);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    	case REQUEST_CHOOSER:	
        	if (resultCode == RESULT_OK) {
				
            	final Uri uri = data.getData();
				
				// Get the File path from the Uri
            	String path = FileUtils.getPath(this, uri);
				
				// Alternatively, use FileUtils.getFile(Context, Uri)
				if (path != null && FileUtils.isLocal(path)) {
					File file = new File(path);
				}
        	}
			break;
    }
}

A more robust example can be found in the aFileChooserExample project.

Note the FileUtils method to get a file path from a Uri (FileUtils.getPath(Context, Uri)). This works for File, MediaStore, and DocumentProvider Uris.

Credits

Developed by Paul Burke (iPaulPro) - paulburke.co

Translations by TomTasche, booknara, brenouchoa

Folder by Sergio Calcara from The Noun Project (ic_provider.png)

Document by Melvin Salas from The Noun Project (ic_file.png)

Licenses

Copyright (C) 2011 - 2013 Paul Burke

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Portions of FileUtils.java:

Copyright (C) 2007-2008 OpenIntents.org

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

LocalStorageProvider.java:

Copyright (c) 2013, Ian Lake
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.	

afilechooser's People

Contributors

booknara avatar brenouchoa avatar cannonpalms avatar holoceo avatar ipaulpro avatar ruiaraujo avatar tomtasche avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

afilechooser's Issues

Mime type not taken

While adding
intent.setType("video/*");
on FileUtils. createGetContentIntent()

or adding on Manifest file also like

FileChooserActivity won't consider these Mime types but other FileBrowser Application installed on the phone will take this Mime type consideration

Unfortunately, Documents has stopped

I am using library in my project but when i select any image then it shows me an alert with Unfortunately, Documents has stopped, here i am able to get exact path of file but everytime i am getting this Document crash issue on file choose for api above kitkat.

Google Drive not working

Hi, as in topic.
In example app, when i select file from Google Drive returned value is null.
Box, Dropbox works fine.

Cannot receive result from started FileChooser activity

Hi Paul,

Firstly, thanks for your effort in making this FileChooser which is really neat.

However, following the way from your Readme and code from example, I have encountered problems in getting

intent result from the FilePicker which is my version of activity extends the FileChooser.

Heres the codes:

I starts the activity by:

                Intent in = new Intent(v.getContext(),
                        org.vc.FilePicker.FilePicker.class);
                in.setAction(Intent.ACTION_GET_CONTENT);
                startActivityForResult(in, REQUEST_CODE);

OnActivityResult:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK)
        if (requestCode == REQUEST_CODE) {
            if (data.hasExtra("tmp")) {
                String tmp = data.getStringExtra("tmp");
                Toast.makeText(this, "filename: " + tmp, Toast.LENGTH_LONG).show();
                Log.i("Filename:", tmp);
            }
        }
}

In the newly created FilePicker Activity:

 @Override
 public void finish() {
 Intent data = new Intent();
 Log.i("&&&&&&&&&& PATH", tmp);
 data.putExtra("tmp", tmp);
 setResult(RESULT_OK, data);
 super.finish();
 }

This setting turns out to be no result could be fetched by the

main Activity although the FilePicker works perfectly on picking files.

PS: for some reason, my testing Log.i(); outputs never triggers or could not be found in

logcat neither.

Thanks in advance, looking forward for you reply.

Would be nice to be able to change dir into an external sd card.

I tried the example code provided, prior to integrate aFileChooser in an app of mine I'm trying to develop. I haven't been able to change directory into my external sdcard (/storage/sdcard1 or /mnt/extSdCard), remaining into the internal one (/storage/sdcard0 or /mnt/sdcard).
Other than this, It's a great opportunity to be able to use such a good coding example.
Thanks.

Unsupported column: _data

I have crashes with the library. Device is Nexus 5 with Android 4.4.2. Trace is
Caused by: java.lang.UnsupportedOperationException: Unsupported column: _data
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:169)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:413)
at android.content.ContentResolver.query(ContentResolver.java:461)
at android.content.ContentResolver.query(ContentResolver.java:404)
at com.ipaulpro.afilechooser.utils.FileUtils.getDataColumn(FileUtils.java:218)
at com.ipaulpro.afilechooser.utils.FileUtils.getPath(FileUtils.java:319)

How to fix this?

NoClassDefFoundError when using aFileChooser with my app.

Hello,

I get the exception linked below when I select the built-in aFileChooser to select a file for my app to process. The sample provided with aFileChooser works fine, however.

http://pastebin.com/hXaJ0jQ7

Instead of adding the aFileChooser project as a dependency, I copied the JAR file to my project's libs folder and added it to the build path. I did this because I host my project on Google Code and I didn't want anyone cloning my repository to have to clone other repositories as well.

Design flaw

I have two apps into which which a added aFileChooser (patched version with extension filter and base path).

When I started the demo for testing I saw:

device-2014-01-02-140928

Now I have three identical choose files options.

That makes me wonder if there is not fundamental design flaw inside aFileChooser. I beginn to think that one library can not be an external and internal file chooser at the same time.

Google drive file - KitKat

In kitkat you can select files directly from google: content://com.google.android.apps.docs.storage/document/acc%3D4%3Bdoc%3D2279
is there a way to get the file?

public static boolean isGoogleDriveDocument(Uri uri) {
return "com.google.android.apps.docs.storage".equals(uri.getAuthority());
}

Include in React Native

Hi, I would like to use this in React Native.
I don't know how to include this in my project.

I have added the Jar file in /libs
but the thing i add to AndroidManifest.xml looks like this
image

I have no real experience with android development, but this is probably easy for someone that has.

No usage of AppCompatLibrary (V7)

When using aFileChooser at API Level < 11 ActionBar is not supported. This is no longer required because the AppCompatLibrary supports ActionBar on lower API levels.

Changing this is easy. Add the android-support-v7-appcompat library to the project, adjust a few lines of code and set Theme.AppCompat as the parent theme for all Activities.

Tested with the Example App on Android 2.3.3 in the Emulator.

Here is my Code for FileChooserActivity to achieve this.

/*

  • Copyright (C) 2013 Paul Burke
    *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at
    *
  •  http://www.apache.org/licenses/LICENSE-2.0
    
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.
    */

package com.ipaulpro.afilechooser;

import java.io.File;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentManager.BackStackEntry;
import android.support.v4.app.FragmentManager.OnBackStackChangedListener;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.ActionBar; // Support Lib V7
import android.support.v7.app.ActionBarActivity; // Support Lib V7
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;

/**

  • Main Activity that handles the FileListFragments
    *

  • @Version 2013-06-25

  • @author paulburke (ipaulpro)
    */
    // Support Lib V7 ActionBarActivity instead of Fragment
    public class FileChooserActivity extends ActionBarActivity implements
    OnBackStackChangedListener, FileListFragment.Callbacks {

    public static final String PATH = "path";
    public static final String EXTERNAL_BASE_PATH = Environment
    .getExternalStorageDirectory().getAbsolutePath();

    private FragmentManager mFragmentManager;
    private BroadcastReceiver mStorageListener = new BroadcastReceiver() {
    @OverRide
    public void onReceive(Context context, Intent intent) {
    Toast.makeText(context, R.string.storage_removed, Toast.LENGTH_LONG).show();
    finishWithResult(null);
    }
    };

    private String mPath;

    @OverRide
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mFragmentManager = getSupportFragmentManager();
    mFragmentManager.addOnBackStackChangedListener(this);
    
    if (savedInstanceState == null) {
        mPath = EXTERNAL_BASE_PATH;
        addFragment();
    } else {
        mPath = savedInstanceState.getString(PATH);
    }
    
    setTitle(mPath);
    

    }

    @OverRide
    protected void onPause() {
    super.onPause();

    unregisterStorageListener();
    

    }

    @OverRide
    protected void onResume() {
    super.onResume();

    registerStorageListener();
    

    }

    @OverRide
    protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    outState.putString(PATH, mPath);
    

    }

    @OverRide
    public void onBackStackChanged() {

    int count = mFragmentManager.getBackStackEntryCount();
    if (count > 0) {
        BackStackEntry fragment = mFragmentManager.getBackStackEntryAt(count - 1);
        mPath = fragment.getName();
    } else {
        mPath = EXTERNAL_BASE_PATH;
    }
    
    setTitle(mPath);
    // Support Lib V7
    supportInvalidateOptionsMenu();
    

    }

    @OverRide
    public boolean onCreateOptionsMenu(Menu menu) {
    boolean hasBackStack = mFragmentManager.getBackStackEntryCount() > 0;

     // Support Lib V7
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(hasBackStack);
    actionBar.setHomeButtonEnabled(hasBackStack);
    
    return true;
    

    }

    @OverRide
    public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
    mFragmentManager.popBackStack();
    return true;
    }

    return super.onOptionsItemSelected(item);
    

    }

    /**

    • Add the initial Fragment with given path.
      */
      private void addFragment() {
      FileListFragment fragment = FileListFragment.newInstance(mPath);
      mFragmentManager.beginTransaction()
      .add(android.R.id.content, fragment).commit();
      }

    /**

    • "Replace" the existing Fragment with a new one using given path. We're

    • really adding a Fragment to the back stack.
      *

    • @param file The file (directory) to display.
      */
      private void replaceFragment(File file) {
      mPath = file.getAbsolutePath();

      FileListFragment fragment = FileListFragment.newInstance(mPath);
      mFragmentManager.beginTransaction()
      .replace(android.R.id.content, fragment)
      .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
      .addToBackStack(mPath).commit();
      }

    /**

    • Finish this Activity with a result code and URI of the selected file.
      *
    • @param file The file selected.
      */
      private void finishWithResult(File file) {
      if (file != null) {
      Uri uri = Uri.fromFile(file);
      setResult(RESULT_OK, new Intent().setData(uri));
      finish();
      } else {
      setResult(RESULT_CANCELED);
      finish();
      }
      }

    /**

    • Called when the user selects a File
      *
    • @param file The file that was selected
      */
      @OverRide
      public void onFileSelected(File file) {
      if (file != null) {
      if (file.isDirectory()) {
      replaceFragment(file);
      } else {
      finishWithResult(file);
      }
      } else {
      Toast.makeText(FileChooserActivity.this, R.string.error_selecting_file,
      Toast.LENGTH_SHORT).show();
      }
      }

    /**

    • Register the external storage BroadcastReceiver.
      */
      private void registerStorageListener() {
      IntentFilter filter = new IntentFilter();
      filter.addAction(Intent.ACTION_MEDIA_REMOVED);
      registerReceiver(mStorageListener, filter);
      }

    /**

    • Unregister the external storage BroadcastReceiver.
      */
      private void unregisterStorageListener() {
      unregisterReceiver(mStorageListener);
      }
      }

NullPointerException related to ActionBar

One of my users with a Samsung Galaxy Nexus with android 4.1.1 experienced this:

java.lang.NullPointerException
at com.ipaulpro.afilechooser.FileChooserActivity.boolean onCreateOptionsMenu(android.view.Menu)(ProGuard:125)
at android.app.Activity.onCreatePanelMenu(Activity.java:2503)
at android.support.v4.app.FragmentActivity.boolean onCreatePanelMenu(int,android.view.Menu)(ProGuard:275)
at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:393)
at com.android.internal.policy.impl.PhoneWindow.onKeyDownPanel(PhoneWindow.java:767)
at com.android.internal.policy.impl.PhoneWindow.onKeyDown(PhoneWindow.java:1432)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1826)
at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3733)
at android.view.ViewRootImpl.handleImeFinishedEvent(ViewRootImpl.java:3703)
at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:2933)
at android.os.Handler.dispatchMessage(Handler.java:119)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4873)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:528)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)

Issue getting path from file located on SD card

When using the aFileChooserExample application, I will select a file located on my SD card, and the resulting toast says "File Selected: null". Is there something I have to do to properly retrieve the path from the SD card?

Library does not update issue

Hai,
I'm facing the below issue
After deleting any files in Downloads Es Explorer or file manager in my local storage those deleted files still remains in the library changes does not reflect in aFileChooser library while opening the lib those files also shown in list.

is it possible to set default folder in afilechooser?

I want to set a folder in internal memory to open on that folder when user select "choose file" icon.
I also, do as bellow but it does not work:

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("text/plain");
Uri startDir = Uri.fromFile(new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/myfolder"));

    intent.setDataAndType(startDir,
            "vnd.android.cursor.dir/lysesoft.andexplorer.file");
    intent.addCategory(Intent.CATEGORY_OPENABLE);

    ActivityForResult(
                Intent.createChooser(intent,getString(R.string.choose_file)),
                FILE_SELECT_CODE);

ArrayIndexOutOfBoundsException in FileUtils#getPath if called with root of primary external storage

When the Uri content://com.android.externalstorage.documents/tree/primary%3A/document/primary%3A is fed into FileUtils#getPath, an ArrayIndexOutOfBoundsException is raised, because the docId for this URI is "primary:" and thus splitting this id on ":" gives an array with length 1

The following fixes the problem:

    if ("primary".equalsIgnoreCase(type)) {
      String path = Environment.getExternalStorageDirectory().getPath();
      if (split.length > 1) {
        path += "/" + split[1];
      }
      return path;
    }

java.lang.String java.io.File.getName() throws Null pointer

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.io.File.getName()' on a null object reference
at com.ipaulpro.afilechooser.utils.FileUtils.getMimeType(FileUtils.java:146)

While the uri is : content://com.google.android.apps.docs.storage/document/

Disabling Google Drive from menu

I have been looking around but can't find an answer. Is there an easy way to simply disabling Google Drive from displaying in the fileChooser? That would be a much more simple solution if it is causing an error.

Filter file types

First of all thanks for sharing this awesome piece of work :)

Hey Guys is there a way to filter file types in this library?

I mean I want to limit this chooser to select only pdf or doc files.

Is there anything like this in here already ?

Not Working Library and Demo

I have downloaded Library and just executing Demo, but I am stuck with this problem.

11-06 09:48:15.589: E/AndroidRuntime(15228): FATAL EXCEPTION: main 11-06 09:48:15.589: E/AndroidRuntime(15228): Process: com.android.documentsui, PID: 15228 11-06 09:48:15.589: E/AndroidRuntime(15228): java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.GET_CONTENT cat=[android.intent.category.OPENABLE] typ=*/* flg=0x1000000 cmp=com.desarrollodroide.repos/com.ipaulpro.afilechooser.FileChooserActivity } from ProcessRecord{41ee8330 15228:com.android.documentsui/u0a74} (pid=15228, uid=10074) not exported from uid 10221 11-06 09:48:15.589: E/AndroidRuntime(15228): at android.os.Parcel.readException(Parcel.java:1465) 11-06 09:48:15.589: E/AndroidRuntime(15228): at android.os.Parcel.readException(Parcel.java:1419) 11-06 09:48:15.589: E/AndroidRuntime(15228): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2096) 11-06 09:48:15.589: E/AndroidRuntime(15228): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1419) 11-06 09:48:15.589: E/AndroidRuntime(15228): at android.app.Activity.startActivityForResult(Activity.java:3424) 11-06 09:48:15.589: E/AndroidRuntime(15228): at android.app.Activity.startActivityForResult(Activity.java:3385) 11-06 09:48:15.589: E/AndroidRuntime(15228): at com.android.documentsui.DocumentsActivity.onAppPicked(DocumentsActivity.java:926) 11-06 09:48:15.589: E/AndroidRuntime(15228): at com.android.documentsui.RootsFragment$2.onItemClick(RootsFragment.java:183) 11-06 09:48:15.589: E/AndroidRuntime(15228): at android.widget.AdapterView.performItemClick(AdapterView.java:299) 11-06 09:48:15.589: E/AndroidRuntime(15228): at android.widget.AbsListView.performItemClick(AbsListView.java:1113) 11-06 09:48:15.589: E/AndroidRuntime(15228): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2911) 11-06 09:48:15.589: E/AndroidRuntime(15228): at android.widget.AbsListView$3.run(AbsListView.java:3645) 11-06 09:48:15.589: E/AndroidRuntime(15228): at android.os.Handler.handleCallback(Handler.java:733) 11-06 09:48:15.589: E/AndroidRuntime(15228): at android.os.Handler.dispatchMessage(Handler.java:95) 11-06 09:48:15.589: E/AndroidRuntime(15228): at android.os.Looper.loop(Looper.java:136) 11-06 09:48:15.589: E/AndroidRuntime(15228): at android.app.ActivityThread.main(ActivityThread.java:5001) 11-06 09:48:15.589: E/AndroidRuntime(15228): at java.lang.reflect.Method.invokeNative(Native Method) 11-06 09:48:15.589: E/AndroidRuntime(15228): at java.lang.reflect.Method.invoke(Method.java:515) 11-06 09:48:15.589: E/AndroidRuntime(15228): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) 11-06 09:48:15.589: E/AndroidRuntime(15228): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 11-06 09:48:15.589: E/AndroidRuntime(15228): at dalvik.system.NativeStart.main(Native Method)

Start the FileChooserActivity directly

Hi,

sorry, that I ask with a little problem like this.

Im not able to start the FileChooserActivity directly.
At the moment it is configured like the aFileChooserExample.

private void openFile() {
    // Use the GET_CONTENT intent from the utility class
    Intent target = FileUtils.createGetContentIntent();

    // Create the chooser Intent
    Intent intent = Intent.createChooser(
            target, getString(R.string.chooser_title));

    try {
        startActivityForResult(intent, REQUEST_CODE);

    } catch (ActivityNotFoundException e) {
         //The reason for the existence of aFileChooser
    }
}

I dont want to see the other possibilitys (Music, photos,...) and start the aFileChooser directly.

I tried with :

    private void openFile() {
        Intent in = new Intent("com.ipaulpro.afilechooser.FileChooserActivity");
        startActivityForResult(in, REQUEST_CODE);
    }

or:

    private void openFile() {
        Intent in = new Intent("android.intent.action.GET_CONTENT");
        startActivityForResult(in, REQUEST_CODE);
    }

But I get this message on start:

E/AndroidRuntime(22091): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.ipaulpro.afilechooser.FileChooserActivity }

Can someone tell me, what changes I need?

Thank you very much

Build problem

The DocumentProvider cannot be resolved to a type

Cannot choose file

Hi, i faced an issue when selected the file. Unfortunately i could not select the file by using the android default file chooser. If i used another file chooser (ES File Explorer) it worked.

screenshot_20160616-100803

Everything was disabled :(

afilechooser android 5.0.2

Hallo everybody,

I'm using ipaulpro.afilechooser.FileChooserActivity in my app and it work fine. But it does't work on Samsung Tab (Android 5.0.2). I can choose JPG , PNG but no PDF. Please do you know if there is a Problem on 5.0.2?

Best regards

Displaying Empty Directory in some devices

When click on Choose a File, a progress bar is shown then Empty Directory message is displayed.

I guess, FileChooserActivity is not properly loading the List of files.

  1. Samsung Galaxy s6 edge (SM-G935FD) Android 6.0.1 (23) MARSHMELLOW
  2. LG Nexus 5 (Nexus 5) Android 6.0 (23) MARSHMELLOW

Empty Directory

Build problem

The import of android.provider.DocumentsContractor is not resolved.

Creating a File filter as per file size

Rather than an issue ,it would be an enhancement
Just like filtering the files as per file type, a mechanism to filter files as per their size.
Meaning if the user wants to display images with maximum size of 5 Mb or less,then the file browser will display only those images.

string/chooser——label Not found

When i added the “FileChooserActivity” activity in manifest
i came across such an error

error: Error: No resource found that matches the given name (at 'label' with value
'@string/chooser_label').

Any help, thanks in advance

Problem with Proguard

I was trying to export the example application in the project and was unable to do so. In the aFileChooserExample project, I added the following line in project.properties file -

proguard.config=proguard.cfg

Then I tried to export the project by going to Android Tools > Export signed application package. It gave the following error message -

Conversion to dalvik format failed with error 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.