Closed Arashvscode closed 1 year ago
What is the error/exception you get?
The main problem is here, it doesn't give any error, only the program closes. I also wrote a new code that I am sending to you, it also gives an error.
public static void unzio(Activity activity) {
final ProgressDialog dialog = new ProgressDialog(activity, ProgressDialog.THEME_DEVICE_DEFAULT_DARK);
dialog.setTitle("Unzip.....");
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
dialog.setMax((int) 100);
dialog.show();
Thread thread = new Thread(() -> {
ZipFile zipFile = new ZipFile("/storage/emulated/0/apk/color.zip");
zipFile.setRunInThread(true);
try {
zipFile.extractAll("/storage/emulated/0/apk/");
} catch (ZipException e) {
throw new RuntimeException(e);
}
ProgressMonitor progressMonitor = zipFile.getProgressMonitor();
while (!progressMonitor.getState().equals(ProgressMonitor.State.READY)) {
activity.runOnUiThread(() -> {
dialog.setProgress(progressMonitor.getPercentDone());
});
}
activity.runOnUiThread(() -> {
dialog.dismiss();
});
});
thread.start();
}
``
When you run zip4j in thread mode, any exceptions are stored in ProgressMonitor. Look at the example code here to check for exceptions. Especially this part:
if (progressMonitor.getResult().equals(ProgressMonitor.Result.SUCCESS)) {
System.out.println("Successfully added folder to zip");
} else if (progressMonitor.getResult().equals(ProgressMonitor.Result.ERROR)) {
System.out.println("Error occurred. Error message: " + progressMonitor.getException().getMessage());
} else if (progressMonitor.getResult().equals(ProgressMonitor.Result.CANCELLED)) {
System.out.println("Task cancelled");
}
Hi, I used your code, but it doesn't do anything in Proges Dialog, can you give me a real code example using Proges Dialog?
I am not an Android programmer. Unfortunately, I can't help you with that request. However, I know that a lot of Android projects use zip4j and ProgressMonitor. Maybe there are some open sources ones too with code hosted on github, etc.
aha ok bro tnks to Help me
hi me using in code
end my app Error Not Run Plz help me...