我在Android上使用aFileChoser,出于某种原因,在Android 4.4 Kitkat以下的设备上,当我选择"选择文件"时,应用程序崩溃了。这是我的活动:
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();
}
}
}
这是我的logcat:
08-05 23:05:53.695: E/AndroidRuntime(757): FATAL EXCEPTION: main 08-05 23:05:53.695: E/AndroidRuntime(757): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.dogger20011.mcpemodlocater/com.ipaulpro.afilechooser.FileChooserActivity}: java.lang.ClassNotFoundException: com.ipaulpro.afilechooser.FileChooserActivity 08-05 23:05:53.695: E/AndroidRuntime(757): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880) 08-05 23:05:53.695: E/AndroidRuntime(757): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981) 08-05 23:05:53.695: E/AndroidRuntime(757): at android.app.ActivityThread.access$600(ActivityThread.java:123) 08-05 23:05:53.695: E/AndroidRuntime(757): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147) 08-05 23:05:53.695: E/AndroidRuntime(757): at android.os.Handler.dispatchMessage(Handler.java:99) 08-05 23:05:53.695: E/AndroidRuntime(757): at android.os.Looper.loop(Looper.java:137) 08-05 23:05:53.695: E/AndroidRuntime(757): at android.app.ActivityThread.main(ActivityThread.java:4424) 08-05 23:05:53.695: E/AndroidRuntime(757): at java.lang.reflect.Method.invokeNative(Native Method) 08-05 23:05:53.695: E/AndroidRuntime(757): at java.lang.reflect.Method.invoke(Method.java:511) 08-05 23:05:53.695: E/AndroidRuntime(757): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 08-05 23:05:53.695: E/AndroidRuntime(757): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 08-05 23:05:53.695: E/AndroidRuntime(757): at dalvik.system.NativeStart.main(Native Method) 08-05 23:05:53.695: E/AndroidRuntime(757): Caused by: java.lang.ClassNotFoundException: com.ipaulpro.afilechooser.FileChooserActivity 08-05 23:05:53.695: E/AndroidRuntime(757): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61) 08-05 23:05:53.695: E/AndroidRuntime(757): at java.lang.ClassLoader.loadClass(ClassLoader.java:501) 08-05 23:05:53.695: E/AndroidRuntime(757): at java.lang.ClassLoader.loadClass(ClassLoader.java:461) 08-05 23:05:53.695: E/AndroidRuntime(757): at android.app.Instrumentation.newActivity(Instrumentation.java:1023) 08-05 23:05:53.695: E/AndroidRuntime(757): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871) 08-05 23:05:53.695: E/AndroidRuntime(757): ... 11 more