1

次のコードは、API レベル 11 以降で正常に動作するようです。

   private ZipInputStream getFileFromZip(InputStream zipFileStream) throws FileNotFoundException, IOException {
     ZipInputStream zis = new ZipInputStream(zipFileStream);
     ZipEntry ze = null;
     while ((ze = zis.getNextEntry()) != null) {
       Log.w(ACTIVITY_LOG_TAG, "extracting file: '" + ze.getName() + "'...");
       return zis;
     }
     return null;
    }

しかしIOException、たとえば 10 や 8 未満で実行するとスローされます。これらの API も自分のアプリでサポートしたいので、これを機能させる必要があります...

すべてのファイル名、パスなどを確認しました。また、3.0 で動作します。また、zip 入力ストリームには影響しないはずですが、actionbarsherlock も使用しています。

誰にもアイデアはありますか?

アップデート

を使用してこれを行っていることを忘れていましたAsyncTask<Void, Void, Void>

Blackbelt から要求された LogCat:

06-08 11:12:17.478: E/AndroidRuntime(405): FATAL EXCEPTION: AsyncTask #1
06-08 11:12:17.478: E/AndroidRuntime(405): java.lang.RuntimeException: An error occured while executing doInBackground()
06-08 11:12:17.478: E/AndroidRuntime(405):  at android.os.AsyncTask$3.done(AsyncTask.java:200)
06-08 11:12:17.478: E/AndroidRuntime(405):  at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
06-08 11:12:17.478: E/AndroidRuntime(405):  at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
06-08 11:12:17.478: E/AndroidRuntime(405):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
06-08 11:12:17.478: E/AndroidRuntime(405):  at java.util.concurrent.FutureTask.run(FutureTask.java:137)
06-08 11:12:17.478: E/AndroidRuntime(405):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
06-08 11:12:17.478: E/AndroidRuntime(405):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
06-08 11:12:17.478: E/AndroidRuntime(405):  at java.lang.Thread.run(Thread.java:1096)
06-08 11:12:17.478: E/AndroidRuntime(405): Caused by: android.database.sqlite.SQLiteException: Unable to extract databases/RGBColortype.zip to data directory
06-08 11:12:17.478: E/AndroidRuntime(405):  at android.content.res.AssetManager.readAsset(Native Method)
06-08 11:12:17.478: E/AndroidRuntime(405):  at android.content.res.AssetManager.access$700(AssetManager.java:36)
06-08 11:12:17.478: E/AndroidRuntime(405):  at android.content.res.AssetManager$AssetInputStream.read(AssetManager.java:574)
06-08 11:12:17.478: E/AndroidRuntime(405):  at java.io.PushbackInputStream.read(PushbackInputStream.java:198)
06-08 11:12:17.478: E/AndroidRuntime(405):  at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:212)
06-08 11:12:17.478: E/AndroidRuntime(405):  at com.coloruapp.MainActivity.getFileFromZip(MainActivity.java:346)
06-08 11:12:17.478: E/AndroidRuntime(405):  at com.coloruapp.MainActivity.copyDatabaseFromAssets(MainActivity.java:321)
06-08 11:12:17.478: E/AndroidRuntime(405):  at com.coloruapp.MainActivity.access$2(MainActivity.java:315)
06-08 11:12:17.478: E/AndroidRuntime(405):  at com.coloruapp.MainActivity$DBInstaller.doInBackground(MainActivity.java:294)
06-08 11:12:17.478: E/AndroidRuntime(405):  at com.coloruapp.MainActivity$DBInstaller.doInBackground(MainActivity.java:1)
06-08 11:12:17.478: E/AndroidRuntime(405):  at android.os.AsyncTask$2.call(AsyncTask.java:185)
06-08 11:12:17.478: E/AndroidRuntime(405):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
06-08 11:12:17.478: E/AndroidRuntime(405):  ... 4 more

そしてその後、私は明らかに漏れProgressDialogます...

06-08 11:12:19.058: D/ActionBarSherlock(405): [dispatchStop]
06-08 11:12:19.138: E/WindowManager(405): Activity com.coloruapp.MainActivity has       leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@46090078 that was originally added here
06-08 11:12:19.138: E/WindowManager(405): android.view.WindowLeaked: Activity com.coloruapp.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@46090078 that was originally added here
06-08 11:12:19.138: E/WindowManager(405):   at android.view.ViewRoot.<init>   (ViewRoot.java:247)
06-08 11:12:19.138: E/WindowManager(405):   at  android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
06-08 11:12:19.138: E/WindowManager(405):   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
06-08 11:12:19.138: E/WindowManager(405):   at android.view.Window$LocalWindowManager.addView(Window.java:424)
06-08 11:12:19.138: E/WindowManager(405):   at android.app.Dialog.show(Dialog.java:241)
06-08 11:12:19.138: E/WindowManager(405):   at     com.coloruapp.MainActivity$DBInstaller.onPreExecute(MainActivity.java:310)
06-08 11:12:19.138: E/WindowManager(405):   at android.os.AsyncTask.execute(AsyncTask.java:391)
06-08 11:12:19.138: E/WindowManager(405):   at com.coloruapp.MainActivity.onCreate(MainActivity.java:92)
06-08 11:12:19.138: E/WindowManager(405):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-08 11:12:19.138: E/WindowManager(405):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
06-08 11:12:19.138: E/WindowManager(405):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
06-08 11:12:19.138: E/WindowManager(405):   at android.app.ActivityThread.access$2300(ActivityThread.java:125)
06-08 11:12:19.138: E/WindowManager(405):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
06-08 11:12:19.138: E/WindowManager(405):   at android.os.Handler.dispatchMessage(Handler.java:99)
06-08 11:12:19.138: E/WindowManager(405):   at android.os.Looper.loop(Looper.java:123)
06-08 11:12:19.138: E/WindowManager(405):   at android.app.ActivityThread.main(ActivityThread.java:4627)
06-08 11:12:19.138: E/WindowManager(405):   at java.lang.reflect.Method.invokeNative(Native Method)
06-08 11:12:19.138: E/WindowManager(405):   at java.lang.reflect.Method.invoke(Method.java:521)
06-08 11:12:19.138: E/WindowManager(405):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-08 11:12:19.138: E/WindowManager(405):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-08 11:12:19.138: E/WindowManager(405):   at dalvik.system.NativeStart.main(Native Method)
4

0 に答える 0