GLBasic forum

Main forum => GLBasic - en => Topic started by: Kyo on 2014-May-29

Title: Read file error
Post by: Kyo on 2014-May-29
I use this simple code:

Code (glbasic) Select

SETCURRENTDIR("Media") // go to media files

AUTOPAUSE TRUE
SEEDRND GETTIMERALL()

//SETSCREEN 9999,9998,FALSE
SETSCREEN 440,700,FALSE

int_sd$ = PLATFORMINFO$("APPDATA")
ext_sd$ = PLATFORMINFO$("DOCUMENTS")


WHILE TRUE

PRINT "Int_sd: " + int_sd$, 0, 10
PRINT "Ext_sd: " + ext_sd$, 0, 20

PRINT "Path: " + GETCURRENTDIR$(), 0, 30

PRINT "**************2", 0, 50

OPENFILE(1,"1.txt", TRUE)
READLINE 1, nome$
PRINT "1 : " + nome$,0 ,70
CLOSEFILE 1


SHOWSCREEN
WEND


In Windows work fine but in Android Crash...
I use DOESFILEEXIST() but it tells me that the file does not exist.

I test a various option:
OPENFILE(1,"Media/1.txt", TRUE)
or
OPENFILE(1,"Media\1.txt", TRUE)

but the file not found!
Title: Re: Read file error
Post by: Kyo on 2014-May-29
mmmm it's error of Android Extras .....

I do not know why but it does not work the command: SETCURRENTDIR("Media")

Title: Re: Read file error
Post by: Ian Price on 2014-May-31
Quote from: Kyo on 2014-May-29
mmmm it's error of Android Extras .....

I do not know why but it does not work the command: SETCURRENTDIR("Media")



I don't think this is an AE issue - Android's file system seems to be problematic with GLBasic. From my own personal experience with OUYA and GameStick (both Android deveices) AE has helped in lots of areas where GLBasic falls far short. Try compiling your GLB program for Android without AE and see if you get the same result.

In AE you need to use Android.Check_Asset("") prior to loading media using the standard LOADANIM etc. commands

Remember Android is very specific with regards to case sensitivity too, which include the format (eg .png/.PNG etc.)
Title: Re: Read file error
Post by: spacefractal on 2014-Jun-01
SETCURRENTDIR("Media") is done automatic with AE. This is required so Android.Check_Assest() could work, so they looking in the same path. This is due SETCURRENTDIR() did not set dir in the Java part, only in c++ Part.

But you need add Android.Check_Assest(file$) before any loading commands. Its to skips the ... screen.
Title: Re: Read file error
Post by: Kyo on 2014-Jun-01
Thanks for reply!

But ADmob works????
How to set a Banner Positon, Dimension etc????
Title: Re: Read file error
Post by: spacefractal on 2014-Jun-01
only fullscreen ads works, not onscreen banners. Again, see Android Sample.

PS. Can this thread moved to the glbasic en forum, this is not a faq me thinks.
Title: Re: Read file error
Post by: MrTAToad on 2014-Jun-01
You should be checking the result from OPENFILE too - as it could be failing there...
Title: Re: Read file error
Post by: spacefractal on 2014-Jun-01
you still need a Android.Check_Asset("") if you using internal txt file. There is also Android.Android_DirCopy (here im forget to remove Android_ from the function name, if you want to copy the whole dir from the apk to the memory.

Etc glbasic can only read from the internal/sd memory, not from APK file, which is in AE not copied automatic. That hence you need those commands.
Title: Re: Read file error
Post by: Kyo on 2014-Jun-02
Thanks for help and sorry for having written in the wrong section!  :booze:

I'm waiting for the version which you can block then autolight off .

Thank for your BIG work spacefractal  :nw:
Title: Re: Read file error
Post by: spacefractal on 2014-Jun-02
until im release a new AE, which im do in this incoming weekend, you can add this line in the public class SDLActivity extends Activity { class in SDLActivity.java, just before // >>>>>>>> END ANDROID EXTRAS <<<<<<<< line (around line 414):

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

this keep the screen on.
Title: Re: Read file error
Post by: Kyo on 2014-Jun-02
Thanks spacefractal you are Boss  :nw: