Android Question ArchiverPlus crashes

ilan

Expert
Licensed User
Longtime User
hi

i am using ArchiverPlus lib made by @Informatix and i am getting crashes when i try to use it.

*** Service (starter) Create ***
6
jd: 2458313.0705875
Freitag:
19:50 | 16:41:38
zmanit:10
shabbat = false
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (firebasemessaging) Create ***
** Service (firebasemessaging) Start **
subscribe to topics called
adview1: received ad
main_archiver_zipresult (java line: 988)
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
at android.os.Handler.<init>(Handler.java:203)
at android.os.Handler.<init>(Handler.java:117)
at android.app.Dialog.<init>(Dialog.java:142)
at android.app.AlertDialog.<init>(AlertDialog.java:201)
at android.app.AlertDialog.<init>(AlertDialog.java:197)
at android.app.AlertDialog.<init>(AlertDialog.java:142)
at android.app.ProgressDialog.<init>(ProgressDialog.java:105)
at android.app.ProgressDialog.show(ProgressDialog.java:209)
at android.app.ProgressDialog.show(ProgressDialog.java:189)
at anywheresoftware.b4a.keywords.Common.ProgressDialogShow2(Common.java:731)
at www.sagital.buysmart.main._archiver_zipresult(main.java:988)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:191)
at a.a.a.f.a.a(SourceFile:88)
at a.a.a.f.a.c(SourceFile:155)
at a.a.a.f.a.a(SourceFile:163)
at a.a.a.i.a.a(SourceFile:190)
at a.a.a.i.a$1.run(SourceFile:1101)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)

is it a problem in the lib or maybe in my code??

this is my code:

B4X:
            Arc.AddFilesToZip(filelist,File.DirInternal & "/" & myuserid & ".zip","Archiver")   


Sub Archiver_ZipResult(Result As Int, ErrorMsg As String)
    Select Result
        Case Arc.ZIP_RESULT_SUCCESS
            Select zipid 
                Case 0
                    If File.Exists(File.DirInternal, myuserid & ".zip") Then 
                        ProgressDialogShow2(stringconvert.returnStr(55),False)
                        initializecl
                        uploadnow   
                    End If                   
                Case 1
                    Log("SUCCESSFULLY unzipped")
                    loadcontacts
            End Select
        Case Arc.ZIP_RESULT_ERROR
            Select zipid 
                Case 0
                    ToastMessageShow(stringconvert.returnStr(56),False)
                    Log("error creating zip: " & ErrorMsg)                       
                Case 1
                    ToastMessageShow(stringconvert.returnStr(57),False)
                    Log("error creating zip: " & ErrorMsg)   
            End Select
    End Select
End Sub
 

ilan

Expert
Licensed User
Longtime User
Looks like ZipResult is raised on a different thread. This is problematic.

Try to use CallSubDelayed to call a different sub from ZipResult.

I tried it but it still didnot work. Informatix send me a mail saying that the error was caused because i used a progressdialog. He said that i should not update any view or use any dialogs in the zip_result event.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
I expect CallSubDelayed to work. Have you moved all the code to the new sub that is called?

yes, you are right, using callsubdelayed did works. i used before callsubdelayed but not from the zip_result event. I thought the arc.addfilestozip(...) should be called with callsubdelayed and now i moved everything from the zipresult event and called it with callsubdelayed and it worked.

thank you very much :)

It's the solution that I gave in my email.

indeed, you wrote it and i follow all your instructions, i just had to get back home and try what you wrote to me. i tried it before your mail with callsubdelayed but did it wrong. anyway, thank you very much for your fast support. :) everything is working fine now!
 
Upvote 0
Top