I'm using aFileChooser to select files within my Android app, and it works great on Kitkat devies, but any device running something older then Kitkat crashes when I select "Choose a file". Here's my activity:

public class aFileChooser extends Activity {

private static final int REQUEST_CHOOSER = 1234;

public void onCreate(Bundle savedInstanceState) {

// Create the ACTION_GET_CONTENT Intent
Intent getContentIntent = FileUtils.createGetContentIntent();

Intent intent = Intent.createChooser(getContentIntent, "Select a file");
startActivityForResult(intent, REQUEST_CHOOSER);

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);

                String zipFile = path; 
                String unzipLocation = Environment.getExternalStorageDirectory() + 

                Decompress d = new Decompress(zipFile, unzipLocation); 

                Toast.makeText(aFileChooser.this, "Process completed! This map has been   
added to your game!", Toast.LENGTH_LONG).show();





Related posts

Recent Viewed