1
이 코드를 사용하면 내 phonegap 응용 프로그램이 응답하지 않거나 시간 제한 창이 포커스 문제/appwindowtoken 등입니다. 기본적으로 앱이로드되지만 검은 색 화면이 표시되며 모든 것이 고정됩니다.phonegap 안드로이드 응용 프로그램이 응답하지 않습니다
아마도 주요 활동을 많이 처리하고 있습니다. 파일을 추출하려고합니다.
어떻게 수정합니까?
코드가 좋습니다. 사전에
덕분에,
제레미
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import org.apache.cordova.*;
public class tester extends DroidGap
{
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Set by <content src="index.html" /> in config.xml
super.loadUrl(Config.getStartUrl());
//super.loadUrl("file:///android_asset/www/index.html")
File extStore = Environment.getExternalStorageDirectory();
File file = new File(extStore.getAbsolutePath()+"/mysoundboard/com.test.dsoundfxboard/1.dat");
if(! file.exists())
{
boolean test = noiser.extractZip(extStore.getAbsolutePath()+"/mysoundboard/mydsoundfxboard.zip", extStore.getAbsolutePath()+"/mysoundboard/com.test.dsoundfxboard/");
FileOutputStream fOut = null;
OutputStreamWriter osw = null;
if(test == true)
{
try {
fOut openFileOutput(extStore.getAbsolutePath()+"/mysoundboard/com.test.dsoundfxboard/1.dat",MODE_WORLD_READABLE);
osw = new OutputStreamWriter(fOut);
osw.write('1');
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
osw.flush();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
osw.close();
fOut.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
private static boolean extractZip(String pathOfZip,String pathToExtract)
{
int BUFFER_SIZE = 1024;
int size;
byte[] buffer = new byte[BUFFER_SIZE];
try {
File f = new File(pathToExtract);
if(!f.isDirectory()) {
f.mkdirs();
}
ZipInputStream zin = new ZipInputStream(new BufferedInputStream(new FileInputStream(pathOfZip), BUFFER_SIZE));
try {
ZipEntry ze = null;
while ((ze = zin.getNextEntry()) != null) {
String path = pathToExtract +"/"+ ze.getName();
if (ze.isDirectory()) {
File unzipFile = new File(path);
if(!unzipFile.isDirectory()) {
unzipFile.mkdirs();
}
}
else {
FileOutputStream out = new FileOutputStream(path, false);
BufferedOutputStream fout = new BufferedOutputStream(out, BUFFER_SIZE);
try {
while ((size = zin.read(buffer, 0, BUFFER_SIZE)) != -1) {
fout.write(buffer, 0, size);
}
zin.closeEntry();
}catch (Exception e) {
Log.e("Exception", "Unzip exception 1:" + e.toString());
}
finally {
fout.flush();
fout.close();
}
}
}
}catch (Exception e) {
Log.e("Exception", "Unzip exception2 :" + e.toString());
}
finally {
zin.close();
}
return true;
}
catch (Exception e) {
Log.e("Exception", "Unzip exception :" + e.toString());
}
return false;
}
}