Trying to create my first Android app (simple download and unzip)

Just starting out? Need help? Post your questions and find answers here.
miskox
Posts: 6
Joined: Sun Jan 01, 2023 12:59 am

Trying to create my first Android app (simple download and unzip)

Post by miskox »

Hello all!

I am trying to create my first Android app: all it has to do is download a file, rename it if required, extract the contents of the file (there will be one file in the archive):

I try to download https://www.kockarna.si/bp/1.1 (kockarna.si is my personal site)
This is a .zip file. Why 1.1 and not *.zip? Because this file is hosted on the Unix/Linux system and it doesn't matter if I use lowercase 1 or uppercase 1 :) .

Then I would like to extract the file that is stored in the .zip file (password is 123).

I am stuck at the download already. Here is the code. I based it on the http.sb example:

Code: Select all

;No debug
CloseDebugOutput()

; download https://www.kockarna.si/bp/1.1
; rename to 1.zip if required
; unzip 1.1 (or 1.zip) to 'downloads'
;

Procedure HttpGetEvent(Success, Result$, UserData)
  If Success
    Debug Result$
  Else
    Debug "HTTPRequest(): Error"
  EndIf
EndProcedure

Procedure ButtonEvent()
  HTTPRequest(#PB_HTTP_Get, "https://www.kockarna.si/bp/1.1", "", @HttpGetEvent())
  ; 1.1 is .zip file
  ; password for zip 123
EndProcedure

If OpenWindow(0, 100, 100, 250, 100, "Download 1.1")
  ButtonGadget(0, 10, 10, 250, 100, "Download 1.1")
  BindGadgetEvent(0, @ButtonEvent())
EndIf
I can't see that anything is downloaded (and I don't know where to look for it).

I really have no clue what to do.

And it looks like it opens in full window - I don't want to open in full window. In my settings I have 'fullscreen' unchecked.

Any help would be very useful.

Thanks.
Saso
plouf
Posts: 295
Joined: Tue Feb 25, 2014 6:01 pm
Location: Athens,Greece

Re: Trying to create my first Android app (simple download and unzip)

Post by plouf »

In general you can only download /retrieve data from the same server script is running
So if you run hosted in your pc .. its not in the same server (local vs kokarna)

For testing purposws tou can download a cors plugin for tour browser . But definitelly not on final app
Christos
miskox
Posts: 6
Joined: Sun Jan 01, 2023 12:59 am

Re: Trying to create my first Android app (simple download and unzip)

Post by miskox »

Thanks. Then it looks like I have a problem.

Any other solutions?

But this is Android app I am building? This applies for this too?

Saso
plouf
Posts: 295
Joined: Tue Feb 25, 2014 6:01 pm
Location: Athens,Greece

Re: Trying to create my first Android app (simple download and unzip)

Post by plouf »

if you have access to apache config in the http server test this (untested by me)

viewtopic.php?p=8966#p8966

there are also several cordova plugins you can include, but its more "advance"
Christos
miskox
Posts: 6
Joined: Sun Jan 01, 2023 12:59 am

Re: Trying to create my first Android app (simple download and unzip)

Post by miskox »

Thanks.

Something is bothering me: so that would mean that if I want to download a file from a Microsoft website I would have to configure their server.

I don't get it.

We are talking about the Android app (as the post title says). If I open Chrome on my mobile phone and enter file's URL I can downlolad it.

Or this applies only for the development process? So I can have my file on the 127.0.0.1 (or something)?

Saso
plouf
Posts: 295
Joined: Tue Feb 25, 2014 6:01 pm
Location: Athens,Greece

Re: Trying to create my first Android app (simple download and unzip)

Post by plouf »

its a bit tricky because in it's root, spiderbasic basically creates webapp's.
And in the web these limitation apply, since around a decade, because of all these "phising" and scam's, long ago it was all free ;)

So since SB creates an "app" through the cordova framework its a masquerade webapp->android and not "Real-real" app.

cordova however can be modified to access anything, also has plugins you can include and use to do almost anything,
but very few supported out-of-the-box for a number of reason, mainly for complexity
Christos
miskox
Posts: 6
Joined: Sun Jan 01, 2023 12:59 am

Re: Trying to create my first Android app (simple download and unzip)

Post by miskox »

Thanks. This makes things more clear to me (I am a complete noob regarding Android apps).

I tried to change .htaccess file - but it contains completey different syntax.

I guess this project will have to wait.

Saso
Post Reply