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;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.maps);

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

                String zipFile = path; 
                String unzipLocation = Environment.getExternalStorageDirectory() + 
"/games/com.mojang/minecraftWorlds/";

                Decompress d = new Decompress(zipFile, unzipLocation); 
                d.unzip(); 

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


            }
        }

        this.finish();

 }
}

 }

Related posts

Recent Viewed