GLBasic forum

Main forum => FAQ => Topic started by: Kitty Hello on 2011-Oct-01

Title: Share documents with your device (iOS, WebOS, Android)
Post by: Kitty Hello on 2011-Oct-01
If you want some documents to share when synching with your PC/Mac, you have these options:

iOS
In the info.plist add the key: UIFileSharingEnabled=true
Be sure to set the "CFBundleDisplayName ".
You can not see the PLATFORMINFO$("DOCUMENTS") directory in iTunes.

WebOS
You can read/write to "/media/internal", which is the root directory of the USB-drive when connected.
There is a sub-directory "appdata/com.yourcompany.yourapp", as well if you want to put data there instead of the root directory.
Also "/media/internal/downloads" exists, so lots of choices for you.

Android
You must access the Java function " getExternalStoragePublicDirectory()" for this. You do this with:
Code (glbasic) Select

IMPORT "C" const char* android_ext_storage_pub_dir()
LOCAL and_dir$
and_dir$ = android_ext_storage_pub_dir()

and defaults to " /mnt/sdcard/Download" on my device. (which does not exist unless you downloaded a file. Make sure you create this if it's not there).
You need to check for
Code (glbasic) Select

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

in your AndroidManifext.xml file.

Now the best!!! (Drumroll)
If you have CyanogenMod installed on your HP Touchpad, you can use this function to get the very same storage directory for both OSs. That means - one app, WebOS or Android, uses the same "game state" data.
Code (glbasic) Select

// -----------------------------------------------------------
// documents directory. No "/" appended
// -----------------------------------------------------------
FUNCTION gack_project_root$:
// For WebOS -> hardcoded path that allows exchange with USB-drive
?IF DEFINED( WEBOS) OR DEFINED(PALM_PIXI)
RETURN "/media/internal/appdata/com.glbasic.gack"
?ENDIF

?IF DEFINED( ANDROID )
IMPORT "C" const char* android_ext_storage_pub_dir()
LOCAL and_storage$ = android_ext_storage_pub_dir()

IF NOT DOESDIREXIST(and_storage$) THEN CREATEDIR(and_storage$)

// one up
LOCAL pos% = REVINSTR(and_storage$, "/")
IF pos%>0 THEN and_storage$ = LEFT$(and_storage$, pos%)

INC and_storage$, "/appdata"
IF NOT DOESDIREXIST(and_storage$) THEN CREATEDIR(and_storage$)
INC and_storage$, "/com.glbasic.gack"
IF NOT DOESDIREXIST(and_storage$) THEN CREATEDIR(and_storage$)
RETURN and_storage$
?ENDIF


RETURN PLATFORMINFO$("DOCUMENTS") + "/GACK"
ENDFUNCTION


Title: Re: Share documents with your device (iOS, WebOS, Android)
Post by: aroldo on 2011-Oct-01
Thanks for the tip! :coke:
Title: Re: Share documents with your device (iOS, WebOS, Android)
Post by: mentalthink on 2011-Oct-01
THXS!!!
Title: Re: Share documents with your device (iOS, WebOS, Android)
Post by: Ian Price on 2011-Oct-01
I was thinking about asking about this only recently. Cheers :)
Title: Re: Share documents with your device (iOS, WebOS, Android)
Post by: spicypixel on 2011-Oct-10
Probably obvious to most people but how exactly would you share documents for iOS and more specifically for what purpose. I also don't understand this...

You can not see the PLATFORMINFO$("DOCUMENTS") directory in iTunes.

What difference does this make ^
Title: Re: Share documents with your device (iOS, WebOS, Android)
Post by: ampos on 2011-Oct-10
You can sent files to some aplications using itunes. In the app tab of your device, click on an app. It will open a window where you can drop files. This files are sent to the documents folder of the app.

You can not sent folders, just files. And you can not see what is inside the documents folder, just sent files (one way street).

The app with the "documents" windows on itunes are the ones with uifilesahring thing on.

Title: Re: Share documents with your device (iOS, WebOS, Android)
Post by: Kitty Hello on 2011-Oct-10
one way street !?! I thought this directory was sort of a public directory.
Title: Re: Share documents with your device (iOS, WebOS, Android)
Post by: Crivens on 2011-Oct-10
Mine can be a bit hit and miss depending on the app. AVPlayer for example (best video player IMHO) can lose the file list in iTunes (can still add new files). On the other hand it might be because now and again I use NetPortal (brilliant for exploring networks) to copy movies from my NAS over wifi and I think it messes with the Inbox directory a bit in AVPlayer's document directory.

Cheers
Title: Re: Share documents with your device (iOS, WebOS, Android)
Post by: ampos on 2011-Oct-10
Quote from: Kitty Hello on 2011-Oct-10
one way street !?! I thought this directory was sort of a public directory.

You put me on doubt. Anyway you were the first to say "you can not see the content using itunes"
Title: Re: Share documents with your device (iOS, WebOS, Android)
Post by: ampos on 2011-Oct-10
Crivens, if your iThing is JB iFunBox is great to access your iThing filesystem.
Title: Re: Share documents with your device (iOS, WebOS, Android)
Post by: Crivens on 2011-Oct-10
No it isn't. Don't want to risk any problems with developing for it. Maybe not now but just incase Apple clamp down in the future. I'll probably do it to the 3GS once I upgrade the phone.

Cheers
Title: Re: Share documents with your device (iOS, WebOS, Android)
Post by: ampos on 2011-Oct-12
Quote from: ampos on 2011-Oct-10
Quote from: Kitty Hello on 2011-Oct-10
one way street !?! I thought this directory was sort of a public directory.

You put me on doubt. Anyway you were the first to say "you can not see the content using itunes"

I was wrong. You can see "documents" folder content on iTunes (at least, itunes 10.5, the latest). And two way street (put and read files). Still, no able to create folders from iTunes.
Title: Re: Share documents with your device (iOS, WebOS, Android)
Post by: ampos on 2011-Oct-12
Quote from: Kitty Hello on 2011-Oct-01
Android
You must access the Java function " getExternalStoragePublicDirectory()" for this. It's not implemented, yet. On my TODO.
(After next update that's IMPORT "C" const char* android_ext_storage_pub_dir()

And now I need to know how/where to read/write files, so I can place jpg files on the Android and read them using GLBasic  :good:
Title: Re: Share documents with your device (iOS, WebOS, Android)
Post by: spicypixel on 2011-Oct-12
It's a shame we can't just access the images already held on the various devices (photos etc..). Would be great for photo manipulation apps and uploading thumbnails to online high score tables (my own php mysql for that of course) but you get the idea.
Title: Re: Share documents with your device (iOS, WebOS, Android)
Post by: ampos on 2011-Oct-12
Gernot, what about platforminfo$("photos")? 
Title: Re: Share documents with your device (iOS, WebOS, Android)
Post by: MrTAToad on 2011-Oct-12
I did have a C routine that would allow you to retrieve a Linux OS path to the Photo and Music area...
Title: Re: Share documents with your device (iOS, WebOS, Android)
Post by: Kitty Hello on 2011-Oct-13
The problem is, that on iOS you cannot access a "directory", but have to use a function to get/store photos. Pretty lame.

On other OSs you can surely find this out with environment variables.
Title: Re: Share documents with your device (iOS, WebOS, Android)
Post by: ampos on 2011-Oct-13
DO you know about Android?
Title: Re: Share documents with your device (iOS, WebOS, Android)
Post by: spicypixel on 2011-Oct-13
Quote from: Kitty Hello on 2011-Oct-13
The problem is, that on iOS you cannot access a "directory", but have to use a function to get/store photos. Pretty lame.

On other OSs you can surely find this out with environment variables.

Ouch it was iOS I was thinking of  :O
Title: Re: Share documents with your device (iOS, WebOS, Android)
Post by: Kitty Hello on 2011-Oct-13
Yes. The directory that's about to be recieved with the "external storage" parameter points to the "Downloads". Thus, from there "../Pictures" might be a place to start.
Or just go ".." and from there search all directories for images (GETFILESLIST)
Title: Re: Share documents with your device (iOS, WebOS, Android)
Post by: ampos on 2011-Oct-13
Quote from: Kitty Hello on 2011-Oct-13
Yes. The directory that's about to be recieved with the "external storage" parameter points to the "Downloads". Thus, from there "../Pictures" might be a place to start.
Or just go ".." and from there search all directories for images (GETFILESLIST)

ein?  O_O :blink:
Title: Re: Share documents with your device (iOS, WebOS, Android)
Post by: ampos on 2011-Dec-10
Just to note that iFunBox has been updated and can access your apps' documents folders even if your iThing device is not Jailbroken.

If previously it was a must, now it is a sin not to have it if you own a iThing.