RSS

Author Archives: hypernextandroid

About hypernextandroid

TigaByte Software

HAC and Developing on the Kindle Fire

Yesterday we took our initial look at Amazon’s Kindle Fire tablet and were surprised at its quality of build, display and touch response especially as compared to our budget Android tablets. The Kindle Fire runs a modified version of Android Gingerbread and therefore has some differences from the official Google Android Gingerbread. For instance it doesn’t have the buttons Home, Back and Menu that most Android devices have but instead uses a special menu bar at the bottom of its screen.

Running HAC built Apps
Once we had the Kindle booted up and wifi working we used the Kindle Fire’s web browser to load some of the example apps built by HAC from our website’s projects web page. Kindle Fire’s built in web browser is easy to use and we tried several of the demos including Solar System and they all worked. The Android Info demo accurately identified the device hardware as Kindle Fire so anyone building apps with HAC can be sure their app can successfully detect if it is indeed running on a Kindle Fire.

Some Android developers using the official Android SDK have reported a menu bar problem with the Kindle Fire and we were keen to check this out. At the present time the Kindle Fire’s bottom menu bar cannot be programmatically removed by apps built with the official Android SDK and so the bottom 40 pixels of such apps are always hidden. Amazon do make their Kindle SDK available to developers aiming to create apps specifically for the Kindle Fire and their SDK has the necessary functionality to hide, show and detect the bottom menu bar so allowing apps to use the full screen. However, as HAC won’t be using the Kindle SDK we have a fix in mind to limit the affects of the menu bar problem.

We wanted to connect HAC to the Kindle Fire so as to build and debug apps but amazingly the KIndle Fire doesn’t come with the necessary USB micro B connection cable so we had to order one.

Using HAC to launch and debug apps on Kindle Fire
Today our USB connection cable came but before we could connect up the Kindle Fire to our Windows XP development machine we had to modify a couple of files associated with the Android ADB and USB driver. Soon we will have more details on this but for now here is a link on how to do this :-

http://mobile.tutsplus.com/tutorials/android/getting-started-with-kindle-fire-development/

By the way, there is a free editor called Notepad++ that is great for editing such files:-

http://notepad-plus-plus.org/

Once we had the USB drivers set up we plugged in the Kindle Fire and started up HAC. From HAC’s “Manage Devices” menu we could see the attached Kindle Fire and therefore ran the DDMS debugger before testing a few projects. Please note that the current version of HAC (v1.12) was used and had not been modified in any way in order to work with the Kindle Fire so we weren’t sure what to expect.

We tried several demo projects such as Hello World, Android Info, Preschool Sums and Lunar Lander. They all worked but we noticed a few problems such as the Kindle menu bar remaining at the bottom of the screen, sometimes images not updating after pressing the Home button and then returning to the app. At least there we no crashes, the button response and graphics events worked as well. The Lundar Lander game ran smoothly and below is a screenshot that shows the Kindle menu bar at the bottom of the screen.

Lunar Lander on Kindle Fire

Summary
The Kindle Fire is a very good tablet even though it is running a modified Android OS. Apps built by the current version of HAC do run on it although the bottom menu bar is an irritation as it take valuable space that an app could use.
Our next move is to modify the forthcoming v1.13 release of HAC to work even better with the Kindle Fire.

 
 

Tags: ,

Android more reliable than Apple iOS

This short post is about a very interesting article from PCWorld entitled: “Who’s the Smartphone OS Crash Champion?” that presents app crash stats and concludes that Android apps crash far less frequently than iOS apps. For details on the crash reports see the article and its graphs.
http://www.pcworld.com/article/249356/whos_the_smartphone_os_crash_champion.html#tk.hp_fv

Essentially the article examines, quotes and shows the crash results from apps as reported by the mobile app monitoring company Crittercism at
http://www.crittercism.com/index.html

There is also more data and an analysis from Forbes at
http://www.forbes.com/sites/tomiogeron/2012/02/02/does-ios-crash-more-than-android-a-data-dive/

Android and iOS
If one takes a very brief look at the articles it might appear that it is the mobile operating systems crashing whereas the reports are actually about apps crashing. Does it matter? Yes, most certainly, because if the operating system crashes it probably needs a reboot of the phone or tablet device and that could lose the users current work or data. Of course a really badly behaved app can deprive the the operating system of resources and perhaps even make it crash, so crashing apps are still a bad thing.

Why the Differences?
Assuming that on average the percentage  of Android apps crashing is far less than the percentage of iOS apps crashing then why should this be? The authors and commenters give a number of reasons but only detailed analysis would really shed light on what is actually happening. Anyhow, here are a few suggestions they made:-

(1) Is it the operating system? Well Android is better at multi-tasking so perhaps it is better at house-keeping, memory, stability etc. The problem is how to measure this from the reports.

(2) Is it the number of operating systems? They suggest that perhaps because there are so many different versions of each operation system therefore developers are having problems making their apps work on each version. However, their stats were from 33 versions of Android and 23 versions of iOS so one might expect the Android to be worse when the contrary is true.

(3) Is it the memory management? – I’m not an iOS programmer so can’t vouch for it but some iOS programmers say it is much more difficult managing the memory on iOS than on Android as the programmer themselves must do it. If true, this would make it much more likely that newbie programmers on iOS would produce less reliable apps than those on Android.

(4) Is it the development languages? – some say Java is more robust than Objective C although Java certainly gives the inexperienced programmer lots of scope to crash their app.

(5) There is also talk of the inbuilt advertising making apps unstable. That might be true because if something in the app starts connecting to the net it might interfere with the app’s natural stability.

(6) There is also the hardware but Apple tightly controls its hardware whereas Android runs on a wide variety of devices from different manufactures. Again, Android should fare worse than iOS but the opposite is true.

Conclusions
Clearly by the reported stats Android apps crash far less than iOS apps but there doesn’t seem a clear case for why it should be. There are so many variables here, different versions of operating system and hardware, types of app, what the app does, and how it interacts with hardware. Perhaps the Android OS is more stable than iOS, time will tell. However, they are both developing so rapidly, so watch this space.

 
Leave a comment

Posted by on 07/02/2012 in Android OS, iOS

 

5 How To: Create and Use an Emulator (AVD)

Emulators, also known as AVDs(Android Virtual Device) allow users to test their apps on different versions and setups of the Android operating system without having an actual physical device present. Here we will explain how to create an emulator, launch it and run your app/project on it. At the end are a few tips on emulators.

Creating an AVD in three steps
It is very easy to create an Android emulator using the Android AVD Manager.

1) From within HAC, load the Android AVD Manager by using the menu Android and option Android Emulators.
The AVD Manager image below shows it with no AVDs created:-

1 Empty AVD Manager

.
2) To create a new AVD click the New button as shown above and the following window will open.
An AVD needs these options setting:- the name of the AVD, the target Android API to use and the SD Card size in MB as underlined in the picture.

2 Create AVD

.
3) Once the settings have been filled in then click the Create AVD button and it will open the AVD Manager showing the entry for this newly created AVD:-

3 AVD Manager with AVD present

.
Running an Emulator
There are two easy ways to run an emulator. Firstly by using the Android AVD Manager as shown above, in which case just highlight the required emulator and click the Start button. Secondly, from within HAC using its Android Device Manager as shown below. This lists all the AVDs known to HAC in the top half of the window and displays running AVDs and Android devices in the the bottom half. To run an emulator just select it from the upper list then use the HAC menu Go and option Launch Emulator.

HAC Manage Devices

.
Running Project on an Emulator/Device
HAC’s Android Device Manager lists all of the running emulators and Android devices in the bottom list. To run the project on an already running emulator or device just select the target emulator/device from the lower list then use the HAC menu Go and option Run Android.
.
A Few Tips
(1) An emulator’s first run is very slow and newer APIs can take many minutes to start up.
(2) Emulators like Honeycomb and Ice Cream Sandwich do more and so use more resources, therefore on older PCs don’t run non-essential background apps or the emulator might crawl to a halt.
(3) Some of the newer emulators may occasionally crash or freeze during startup but just try again.
(4) Emulator graphics can be very slow but are still very useful in setting up a game or apps screen layout.
(5) If you need to test your game but don’t have an Android device then use older emulators as they will draw more frames/second, run your code faster and be more responsive.
(6) Emulator keyboards can be problematic so use at least one Android device to check its behaviour.
(7) When creating an emulator ignore the density setting as HAC copes automatically with screen scaling.
(8) Test your app on a range of Android emulators.

 
Leave a comment

Posted by on 07/02/2012 in How-to

 

HAC v1.12 with Easy Installer

This update greatly simplifies the installation of HAC and the Android SDK. It also adds some improvements and bug fixes.
HAC users now have the option of using an Easy Installer that can set up HAC and a basic Android SDK in 10 minutes or less depending upon the user’s internet connection speed.

Improvements
During HAC’s first and subsequent runs it is now better at finding the paths to the Android SDK.
A new menu option “Android Emulators” now makes it easier to set up Emulators (also called AVDs).
An important bug has been fixed for non-English Windows systems that affected signing apps with a Private Key.

HAC Installers
As mentioned above there are now two installers available for HAC.
The previous HAC Installer (now called Standard) required the user to either have the Android SDK already setup or to install it themselves. For beginner programers setting up the Android SDK can be daunting as it has many options and can take a few hours to download and fully install.

(1) Standard Installer is about 14MB in size and just installs HAC.
This should be used if you already have the Android SDK installed in your Program Files directory, you are happy with your current Android SDK installation or you are confident in your ability to install the Android SDK.

(2) Easy Installer is about 140MB in size and installs both HAC and a basic Android SDK.
It should be used if the Android SDK is not already installed and you want to get HAC running as quickly as possible. The Android SDK installed by this Easy Installer just installs API 9 (Gingerbread) but can be updated to include the latest or even older APIs.

For further details 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.

 
1 Comment

Posted by on 06/02/2012 in Updates

 

HAC v1.11 Runs On Even More Devices

This update improves HAC’s ability to build Android apps for a wider range of emulators and devices. We tested a variety of apps on the 12 most important Android emulator versions and ensured that they all ran correctly.

It also fixes a bug that prevented apps running on Android 2.3.3 and a bug that prevented menu icons from showing.

For the tests the following programs were successfully run on all the main emulators as listed below:-

* Hello World
* PreSchool Sums
* Solar System
* Lunar Lander

Emulators:-
Target  API
1.6          4
2.0         5
2.01       6
2.1          7
2.2         8
2.31       9
2.33      10
3.00      11
3.10      12
3.20      13
4.00      14
4.03      15

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

The latest update can be downloaded from here:- http://www.hypernextandroid.com/hnfiles/downloads.html

 
Leave a comment

Posted by on 24/01/2012 in Updates

 

HAC v1.10 for Multilingual Android Apps

This update allows HAC to build Android apps that can work in languages other than English.

It includes a HAC project for building a multiscreen Android app that displays the various controls in English, Greek, Russian, Japanese, Chinese Simplified and Chinese Traditional. This app should run on any Android device and still correctly display the different language texts. There is a demo of this app on our Project web page that can be downloaded directly onto an Android device, http://www.hypernextandroid.com/hnfiles/rescreator.html

Currently HAC built Android apps just use the active keyboard and localisation although the user can change it via the user preferences, the app itself cannot yet change them.

Note, the text HAC displays on your PC is dependent upon the language localisation and fonts in your Microsoft Windows operating system.

For further details 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 17/01/2012 in Updates

 

4: How To: Background Multi-tasking Apps

Its such a simple need, you want your app to keep running in the background while the user is sending a text message or playing a game. This behaviour is called background multi-tasking but it can be a big problem for smart-phone software developers

How can running background apps be such a big deal when our desktop/laptop computers run as many apps as we need, and we can switch effortlessly between them? Well there must be something important about multi-tasking otherwise there wouldn’t have been such a long running debate between Android and Apple smart-phone supporters over whose operating system is better at multi-tasking. The truth is that developing apps for smart-phones is very different to developing them for desktop computers because smart-phones currently have very limited computing resources compared to a typical desk-top or lap-top computer. Below is some brief information about developing multi-tasking apps on Android and how HAC makes it easier for the developer.

The Problem of Background Multi-tasking
With modern desktop/laptop computers a user will often have several apps ‘running’ simultaneously and the app developers generally didn’t have to consider what would happen if a user sent their app to the background when switching to another app. The reason desktop developers have an easier time is because the desktop operating system has enough memory(RAM and disk space) to keep all  apps active at once. Contrast the situation on smart-phones which generally have far slower processors and far less memory than typical home computers. As the first smart-phones had such limited computing resources and limited battery life the operating systems often had to  shut down non-essential apps in order to keep the foreground app running. This has traditionally made it much harder for developers to port or write an app for a smartphone because their design must take into account that the app could be shutdown at anytime.

Consider an Android smart-phone and what happens if a user has your app in the foreground but then decides to use another app, perhaps they want to send a text message or play their chess game. Your app is sent to the background and depending upon its design may be deactivated in which case when brought back to the foreground the Android OS will reload it and assume your app has restored its own state.

Android OS distinguishes between Activities and Services. Activities are what the app user interacts with, the screen for instance, and when the app is sent to the background its activity can be deactivated or effectively removed from memory by the operating system. Therefore the app developer must ensure their app’s activity can handle being forcibly removed from memory and restore its previous state when reactivated again. Services by contrast are intended to run continuously and can remain active even when their app’s activity is in the background and has been deactivated.

HAC Apps and Background Multi-tasking
All HAC apps have two components, an Activity and a Service. The activity is the screen(card) that the user will see and interact with, and which the operating system can shut down when the app is pushed to the background. The service is the engine of a HAC app and runs continuously, ready to execute instructions or respond to events, and the operating system will try to keep it running. Usually the engine will be idling and waiting for events to occur such as when the user clicks a button, the GPS system sends new location data or a timer kicks in and request some action. The engine is the core of a HAC app because it holds the apps memory and ensures the app can do whatever the user needs without interruption from other activities such as text messaging, alarm clocks etc.

How to Create your multi-tasking HAC App
When it to comes to creating background apps HAC developers have a much easier time than most other Android software developers because HAC apps can naturally keep running in the background and require no extra coding to get them to multi-task or to restore their state. Developers just have to ensure the app works well in the foreground, and while in the background doesn’t use unnecessary resources. As HAC apps know when they are in the background the developer can switch off screen drawing or get their app to idle if need be. Note, HAC apps can still update their screen while in the background so that when brought to the foreground again their screen is up-to-date. To sum up, developers use the HAC desktop designer to create the user interface(activity) and add their scripts(service) using the Script Editor.

Performance
As HAC apps are able to run continuously in the background it would therefore be helpful to know just how much they affect the Android device’s performance. We carried out a series of tests on an older model of Android phone, a HTC G1, as this would highlight any performance issues due to its relatively low processor speed and memory capacity as compared to newer Android smart-phones.

We did four tests, firstly to see how much CPU and RAM was being used when idling. Then three tests using HAC demo projects that placed an increasing load on the system. In order of increasing load they were, Hello World, GPS Satellite, and Lunar Lander.

Between tests the G1 was switched off to reset it and clear its memory so that all tests were equal. Note, except for the Lunar Lander test, the app screen shots were taken after all the tests were run. Below, as well as the stats, there is also a screen shot of each app as it appears when in the foreground.

To measure performance we used an app called SystemPanel App/Task Manager by NextApp Inc. They also have a lite version on Android MarketPlace. Please note that these test results are only approximate but they do give an indication of how much each app loaded the system.

1 – Idling Performance
The picture below shows the G1 after it had been switched on and was running with no other apps loaded except SystemPanel. The CPU usage is about 5.3% and RAM usage at 27M average.

Android G1 idle

2 – Hello World Performance
The Hello World app uses very few resources and so is a good indicator of how much overhead an empty HAC built Android app has.The pictures below shows the G1 after it had been switched on and only SystemPanel and Hello World were running. The Hello World CPU usage was about 4.6% and effective RAM usage was about 11.1M.

Hello World screen shot

Hello World Overview

Hello Worlds Overview

Hello World Stats

Hello World stats

3 – GPS Satellite Performance
The GPS Satellite app might be expected to use lots of resources when running in the background and actively acquiring GPS satellite data. During the tests it made fix requests every second or so and made about 140 requests in total with most of them being mad when the app was in the background. Note, the app wasn’t sent to the background until satellites were located and fix readings were coming in. The pictures below shows the G1 after it had been switched on and only SystemPanel and GPS Satellite app were running. GPS Satellite app CPU usage was about 10.2% and effective RAM usage was about 12.1M.

GPS screen shot

GPS Overview

GPS Overview

GPS Stats

GPS Stats

4 – Lunar Lander Performance
The Lunar Lander game would be expected to use lots of resources when running in the background and especially use lots of CPU time. The pictures below shows the G1 after it had been switched on and only SystemPanel and Lunar Lander game were running. Two tests were made with the first sending Lunar Lander to the back after a game had finished in which case the CPU usage was about 10.3% and effective RAM usage was about 13.1M. In the second test Lunar Lander was sent to the back after a game had just started in which case the CPU usage was about 19.0% and effective RAM usage was about 14.6M.

The Lunar Lander game

Lunar Lander screen shot

Lunar Lander Overview

Lunar Lander Overview

Lunar Lander Stats Game Over

Lunar Lander Stats

Lunar Lander Game Running

Lunar Lander Stats Game Running

Final Thoughts
Actual numbers are very important for both design and comparison purposes. The tests showed that the CPU usage on an Android G1 smart phone for the Hello World, GPS Satellite, and Lunar Lander game were 4.6%, 10.2% and 19.0% respectively. As the Hello World app effectively sits there doing nothing and uses only 4.6% CPU usage on an old device then most HAC apps while idling should use far less on a modern Android device, that is unless they are very active such as when doing number crunching, drawing graphics, acquiring GPS data etc.

Thankfully for HAC users creating multi-tasking background apps is quite easy and as long as they follow sensible guidelines their apps will place little load on the device. With the newer and more powerful Android smart phones and tablets the ability of devices to run background apps is now no big deal. If you are concerned your users might not like your app running in the background then just tell them your app has the Menu Quit option so they can really quit it.

 
Leave a comment

Posted by on 10/01/2012 in How-to

 

HAC v1.09 for non-English Windows

This update has concentrated on allowing HAC to work with non-English Microsoft Windows operating systems. It hasn’t added any extra functionality to the Android apps it can build.

Prior to this version HAC would only work on a non-English Windows system if it were installed in a folder whose file-path was valid, that is consisted of just ASCII characters. If the file-path was invalid then HAC wouldn’t run properly and would probably crash at startup.

Note, there is still a limitation on non-English Windows systems in that projects should still be placed in a valid file-path otherwise the graphic routines within HAC can have problems. However, this limitation doesn’t affect the building or running of projects on Emulators and Android devices.

For the time being HAC apps still cannot display non-English character sets but we are working on this.

For further details 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 08/01/2012 in Updates

 

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

A

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.

BR

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

BR

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:-

CardLoadImage(1,'Local:splash.jpg',1)

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

A

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:-


TimerSetMode(1,1,10000)

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.

MenuDesigner

BR

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

Splashscreen on Android G1

BR

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.

BR

Roundup
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: Splashscreen.zip

 
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:-
http://www.hypernextandroid.com/binaries/apks/GPS%20Satellite.apk

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.
null

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

Conclusions
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:-http://www.hypernextandroid.com/binaries/apks/GPS%20Satellite.apk
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