Android and IOS

J. Landman Gay jacque at hyperactivesw.com
Thu Jun 30 01:29:48 EDT 2011


On 6/29/11 4:53 PM, Ralph DiMola wrote:
> I went from a 80 col card programmer in 1973 though OS and CGI development
> in the 1980-1990s to VB6 and Java today. I'm new to Livecode (1 month) So go
> easy on me. I see this a rough crowd, but some help by pointing me in the
> right direction would be appreciated.

Welcome. We're not that rough. We even like each other. :)

>
> My apps for both Android and IOS will access SQLite databases. The app is
> coming along fine in the IDE (database access and such). I am in the process
> testing on Android. After Android I will start testing on IOS. So these
> question are Android related but IOS comments would be appreciated.
>
> 1) I have a splash screen that displays an image using the image control.
> Works fine the in IDE, but is blank when run on the Android HW. Image file
> is obviously not available to the app on the HW. The image file is in the
> apk file. How is this referenced to work in both the IDE and HW?

You can either branch to accomodate each environment, or easier, set up 
your hard drive files to mimic what will be on the device. On Android, 
files in the Copy Files inclusion pane will by default be relative to 
the engine, so when you're using a stack in the IDE, make your files 
there relative to the stack location. Set the defaultfolder to the one 
holding your stack and then you can reference them on both platforms the 
same way. The default folder on Android, if you don't change it, is the 
engine folder so you don't have to set it there.

So if you have a folder of images next to the stack on disk (and you've 
set the defaultfolder,) it's path will be "images/splash.png". On 
Android it will be the same.

Re-reading that, it doesn't sound too clear, so ask if you need more.

> 2) I included both the db and splash screen image in the "Copy Files" tab of
> standalone app setting. They are both in the apk file. When I browse the apk
> file after installation in the elusive "data/app" folder and browse the apk
> files "assets" folder the db and splash screen files are there. The real
> question is how to move the db to the equally elusive
> "/data/app/myapp/files" folder on install for R/W access. I put a copy there
> manually for testing my app. I can access the db using the
> specialFolderPath("documents") path. The
> specialFolderPath("engine")&"/assets" path should point to the apk's assets
> folder but I having no luck during the openstack event coping the files
> myself to the "/data/app/myapp/files" folder for R/W access.

I'm not sure exactly what's going on under the hood, but I heard it's 
not as straightforward as you'd think. The advice is to always use the 
built-in specialFolderPaths and just let the engine do what it needs to do:

   put url ("binfile:" & specialFolderPath("engine")&myDb.db) into url 
("binfile:" & specialFolderPath("documents") & myDB.db)

> 3) What type of menu will use the native menu picker(slide with finger) on
> the Android? I see that to use the native view in IOS the menu picker or
> some such thing must be used. I will go there later. For now Android is the
> priority.

A native scroller control isn't there yet, but you can emulate it. 
There's an example in the TickedOff stack shown at the conference, and I 
think at the Summer Academy, but I'm not sure if that's available for 
general download. Basically you just set up a field with the right text 
size and lineheight and then script it to scroll on touch. I'll see if I 
can find an example tomorrow and post it, unless someone else does it first.

> 4) Are there some example of resizing the stack for various screen sizes? I
> have read the grouping of objects is helpful. I also imagine the
> portrait/landscape requires some planning so resizing is practical in both
> orientations. I have seen some resizing code but it is not completely clear
> to me.

There is a lesson here: 
<http://lessons.runrev.com/spaces/lessons/buckets/1004/lessons/28683-Displaying-Assets-On-Differing-Screen-Resolutions>

You need to script each object's rectangle and/or position in response 
to a resizeStack message, which the stack receives when the device 
rotates. You'll also need to run the same resize handler on preOpenStack 
or preOpenCard, based on the screenrect.

Resizing is a pain but once you get the hang of it, it becomes more 
tedious than difficult.

> 5) Does anyone know when GPS access on the Android will be available? Is
> there a workaround?

I don't know, but I'm pretty sure there's no workaround.

> 6) Can you get runtime errors when running on the Android HW? Now all I get
> is nothing.

Yes, and with the older Android plugin there was a log window you could 
open just for that purpose. It got omitted when the Android build was 
integrated into the IDE (and I want it back.) But you can install the 
older plugin and use it just to see the output log, and it won't 
interfere with the IDE at all. I think the plugin can be downloaded from 
your store account.

Once you've installed the plugin (ask if you don't know how) you can 
open it and click the checkbox that opens the logging window. In your 
stack, use "put" with no destination when you want to log something. 
Anything you "put" will go to the log window. I.e.:

   put the time

will show the current time in the logging window. Whenever you have 
something you need to debug, put a "put" near it. To catch errors, place 
an errorDialog handler in your stack. Then if an error occurs, that 
handler can direct it to the logging window:

on errorDialog pErr
   put pErr -- goes to log
end errorDialog

> 8) How do you install app on SD card?

You don't. :( Not yet, anyway.

> 9) Are there any LC APIs for GPS coordinate proximity to zip codes?

I don't know of any but someone else will speak up if one exists, I'm sure.

> I know this is a lot of questions. I have been reading and hacking 24/7 for
> a month now and app is almost complete except for these issues.
> Thanks in advance for any insight!!!!!!!

Hang around, come back, and ask away.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com




More information about the use-livecode mailing list