Monthly Archives: December 2011

3 How to: Making a Splash Screen

Most apps have a splash screen that loads before the app’s working screens and the splash screen can be used to describe the app, show an advert or just look cool. The splash screen can also serve as an About Box that shows whether the user has registered the app or not.

This post will show how to create a splash screen like the one below that will be visible for 10 seconds or the user can skip by touching the onscreen okay button.
Splashscreen on Android G1


Screens and Cards
Before creating our splash screen here is a brief overview about screens in HAC apps.

We use the terminology card to describe a screen in a HAC app. A HAC app is like a deck of playing cards with each card having its own set of controls. Only one card may be visible at a time and the app can move between cards using one of several types of GotoCard command.

The programmer doesn’t have to worry about displaying the controls as they are defined when you create your card inside the HAC designer. Furthermore the card size can be adjusted to automatically fit the screen so the programmer doesn’t have to worry about scaling etc.

The first card in any HAC app is called the Home Card (card 1) and as it always loads first it makes sense to use this card as your splash screen. As the app loads it is possible to immediately jump to another card but more on this later.


Splash Screen
This splash screen will be on the Home Card and will lead to a second card that implements your app’s functionality. At any time the user can return back to the splash screen using a menu option.

Its a good idea when making a new project to create at least two cards, your Home Card splash screen and the second card for content.

1. Create a new project and give it a name you like.

Use the File menu and option New.

Create a new project


2. Create a second card using the New Card button on the toolbar.

Creating a second card

3. Naming a card

You don’t have to rename a card but if your app has more than two cards it easier to recognise them in the toolbar card list. The picture above shows where a card’s name can be changed.

4. Filling in the Splash Screen

Add the command to preload the backdrop image by opening the Script Editor and in the MainCode’s Start Up section add the following command:-


The backdrop image is just an old one from the HyperNext Neural Network analyser project and the CardLoadImage command stretches it to fit the screen. Note, it needs to be placed in the project’s Local folder.
Splashscreen backdrop image


To add a text to a card just use a Text control and fill in it’s text value with something like “Our Simple SplashScreen”

To add a button to a card just use a Button control. Set the button’s text value to something like “Okay” and from the toolbar set its Goto target to card 2.

Adding a timer to  a card is similar to adding any other control, just select the timer from the Toolbar, use the New Timer button, then click on the card to place it.

This timer causes the app to go to the second card and in order to do this it needs some code. The code is simple, just one command, “GotoCard 2”. With the timer selected open its script and add this command to it:-

GotoCard 2

By default when a timer is created it will be in the off state. To activate a timer the TimerSetMode command is used. We need the timer to start counting when the home card opens so the TimerSetMode command should be placed in the card’s handler script. To do this, select the card and open its script then enter this command into it:-


5. Second Card
Just add some text or even leave it blank.

6. Menu option
We now need to modify the default About menu option so that it jumps to the home card. Open the Menu Designer and it should appear as in the image below. Next, select the About item, its in the yellow box, then click the About item as highlighted in blue, then open the Script Editor  using “Edit Script” button and enter the GotoCard command:-

GotoCard 1

Now close the Script Editor and the project should be ready to run or build.



Running the Splash Screen Project
The picture below shows the built app running on an Android G1 phone:

Splashscreen on Android G1


Overriding the Splash Screen
Some apps such as a file utility might not need the splash screen to show at startup as it could irritate the users. In that case you could either put your splash screen on a later card and let the Home Card contain the functionality or else have a GotoCard in the Home Card’s open handler so the splash screen flies by.


By now you should have an idea for making a splash screen for your app. Get into the habit of leaving the Home card free for use as a splash screen. Some apps don’t need a splash screen so in that case you could use one of the later cards for  info about your app. The complete project is available here:

Leave a comment

Posted by on 22/12/2011 in How-to


2 HowTo: GPS Android App

The GPS functionality now available in HAC apps allows a location determining app to be built that can run continuously either in the foreground or background. The ability of HAC apps to run continuously in the background makes developing such a GPS app quite easy. All it needs is an Android device with either GPS hardware or access to a mobile network that can provide location data.
This post gives a basic overview of GPS location finding and shows the major parts of making your own GPS app with HAC. Fuller details are in the GPS example project included with the HAC installer. There is also both a project and a ready built demo of the GPS app on our Projects web page. The GPS demo app can be installed on an Android device from this link:-

GPS and Locations
Location finding refers to determining one’s latitude and longitude and is usually simply referred to as GPS.  There are two forms of location finding, GPS using satellites and Assisted GPS where the location information comes from a Mobile Network.
Satellite GPS is much more accurate than Mobile Network assisted GPS and if several satellites are in view then a fix can be accurate down to a few metres. It takes 3 satellites to give a fix for latitude longitude but 4 satellites to give an altitude fix. However, there are a number of drawbacks with satellite GPS. It can take several minutes to give the first fix and also if the sky is obscured by buildings or rock then the device may fail to see a satellite.
Mobile network or assisted GPS is fast and can usually work indoors. Its drawbacks include network charges plus low accuracy, perhaps few hundred meters, depending upon the location of the mobile network towers.

GPS Usage
There are three main steps in getting location information, Firstly to specify the location provider, GPS or Mobile Network. Secondly to specify when location events should be available. Thirdly responding when a location event occurs and processing the information provided.

GPS Demo
The demo included with HAC and on our website has three screens, for Network, GPS, and both Network GPS. Below is a screenshot of it running on an Android G1 phone. The green text is a count of how many fixes it has received.
GPS screenshot on Android G1
Scripting GPS Demo
As mentioned above there are three steps to acquiring location data and shortened versions of the scripts are shown below. The card displays location values of accuracy, latitude, longitude, altitude and speed using five text controls as shown in the above screenshot. The three scripts are:

1) Specify the location providers, here using both Network and Satellite.
Location Providers

2) Start the location service and request it send update at least very 10000mS and change of 1m.

3) Respond to a GPS data event and process it. The event values indicating a fix is available are 4 for first fix, 5 for location changed and 6 for time changed. This script resides in the GPS event hander.
GPS events

It is quite easy to make a basic GPS app with HAC as it provides all the basic functionality required. It also provides functions for converting from numeric values of latitude & longitude to degree, minute and second values, plus functions for handling bearings from one location to another.
The best way to understand how this all fits together is to run the GPS project and play around with it. You can also test it to see if the app can truly work while in the background – once you have installed the GPS app, started it and have some location data returning then send it to the back for a while and then later look at the green fix count – it should have increased.
The GPS app demo is here:-
A word of caution though as not all Android devices are equal and the results can depend upon the device hardware and your mobile network.

Leave a comment

Posted by on 20/12/2011 in How-to


HAC v1.08 with GPS

V1.08 adds 51 new commands including functions for finding location from GPS and Mobile Network, new card commands and event queue monitoring.

This update also fixes a bug that prevented HAC apps running properly on the Galaxy Tab and some other Android devices. The bug caused a  startup error when the app tried to access the device’s internal orientation sensor. It has now been fixed and hasn’t affected the orientation detection and automatic screen redrawing.

GPS functionality has been added so HAC apps can actively run in the background and obtain location data from Satellite and Mobile networks. Programmers can specify whether to use GPS and or Mobile network to receive location data as often a Mobile Network is not available or else the user does not wish to incur network charges.

The new Card commands and functions make it easier for your app to keep track of its cards. As in HyperCard, HyperNext cards  are really screens and are much easier to create and switch than with the traditional Java development approach.

Programmers can now monitor how many events are in the app’s HyperNext event queue and flush the queue if it becomes overloaded.

The Editfield control has also been improved and an app’s memory requirements reduced.

For a list of improvements see the release notes accompanying HAC and the posts listed in our forums.

Thank you to our forum users and others for submitting such valuable feedback.



Leave a comment

Posted by on 19/12/2011 in Updates