ipaulpro / afilechooser Goto Github PK
View Code? Open in Web Editor NEW[DEPRECATED] Android library that provides a file explorer to let users select files on external storage.
License: Apache License 2.0
[DEPRECATED] Android library that provides a file explorer to let users select files on external storage.
License: Apache License 2.0
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
The app is really nice. One more feature that is missing is being able to choose directory.
Regards,
Give me suggestion so i can modify this for multiple attachment.
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/
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.
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.
The import of android.provider.DocumentsContractor is not resolved.
I am Unable to copy the selected file result from Activity Result.
It says no File Found But I got the file path.
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());
}
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:
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.
I am use aFileChoose , but i am just select only one file in aFileChoose, so how can i select multipal file selecr?
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.
I'm failed use this lib for fragments, child fragments . with call back!
How can we download google drive file ?
Can you give a short example ?
Regards
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.
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.
Hi, as in topic.
In example app, when i select file from Google Drive returned value is null.
Box, Dropbox works fine.
Hello,
I get the exception and stack trace linked below whenever I run the aFileChooserExample project on my Nexus 7. I'm not sure why it's happening.
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.
My app needs a File Browser for "Save As". Previously use OI File Manager PICK_FILE intent which worked find. Can't use your library without that kind of feature.
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
trying to attach .txt or pdf from recent option but it is not working
One minor typo in the German translation:
https://github.com/iPaulPro/aFileChooser/blob/master/aFileChooser/res/values-de/strings.xml#L4
from:
<string name="storage_removed">Speicher wurde entferntet.</string>
to:
<string name="storage_removed">Speicher wurde entfernt.</string>
will you please explain how to import this project in eclipse step by step. THANK YOU
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;
}
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.
/*
http://www.apache.org/licenses/LICENSE-2.0
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);
}
/**
/**
"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();
}
/**
/**
/**
/**
The DocumentProvider cannot be resolved to a type
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?
If I use aFileChooser in the same project with one of the Android Support Libraries, I get a JAR conflict between android-support-v4.jar in aFileChooser and android-support-v4.jar in the Android Support Libraries. This issue is documented on Stack Overflow.
A possible solution is to replace aFileChooser's android-support-v4.jar with the one from the Android Support Libraries.
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
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)
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
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)
gradle build for android studio?
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 ?
Uri generated with FileProvider not contain _data column
https://github.com/iPaulPro/aFileChooser/blob/master/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java#L233
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
can you add the ability to select multiple files at the same time, and if possible at the same time a box "select all / deselect all" ?
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);
Is there any way to use both External and Internal both path. how to achieve on Click of "Selelct a File"
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.
How can i get file path from sd card.
It is not possible in the code which is given
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.
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.
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.