Revision as of 07:31, 20 October 2011 by hamishwillee (Talk | contribs)

Archived:How to develop a Geo-scheduler application - Part 3

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Created: croozeus (31 Jul 2008)
Last edited: hamishwillee (20 Oct 2011)
17 Sep



Finally we have the last article in the series of "How to develop a Geo-Scheduler or a Location Based Scheduler application" The first two articles can be found here- Part 1 and Part 2. If you have followed this series of articles, then after finishing this one, you should be capable enough to create your own location based application.

In this article - Part 3, we would learn about the Application operations (functions) of the Geo-scheduler application. The application operations consists of functions responsible for the UI of the Geo-scheduler. It contains functions which generate menus, selection lists,etc.

Application operations are listed below:

  • ms_handler() : The main screen handler
  • main() : The first and the main screen
  • help() : method for using the help screen
  • tracker() : The main tracker function
  • background_handler() : Provided Background handling options
  • Calling the methods : Sequence in which we call the defined methods.

As the functions are responsible for UI and generating menus, selection lists, they could be modified according to the requirements of the developer.

Lets discuss the above in detail.

Part 3


ms_handler is a short for main screen handler. Using this method - we create a custom menu and a UI. The ms_lb.current() is used to trigger or direct to a specific method.

index= ms_lb.current()

For example if index = 0 then the method to add a new reminder is called - add_reminder()

Thus the code of ms_handler() could be as follows:

# MS option handler.
def ms_handler():
index = ms_lb.current()
if index == 0:
if index == 1:
# Show menu.
editreminder_opts = [u"Location", u"Reminder description"]
search_by = appuifw.popup_menu(editreminder_opts, u"Search by:")
if search_by == 0:
# Edit reminder by location.
if search_by == 1:
# Edit reminder by reminder.
if index == 2:
if index == 3:


This would be the first method to be called on the launch of the application. Its responsibility is to set appuifw.app.body to ms_lb.

where the below is true:

ms_opts = [u"Add Reminder", u"Edit Reminder", u"Add Location", u"Edit Location"]
ms_lb = appuifw.Listbox(ms_opts, ms_handler)

The function can be modified for better enhancement of the UI (may be a startup image on the canvas)

The function also generates a main menu for the application, including options like Help and Start Tracker.

The code for the main() could be as follows:

def main():
appuifw.app.body = ms_lb
appuifw.app.quit = quit
# Set application initial menu.
appuifw.app.menu = [(u"Help", help),(u"Start Tracker", background_handler)]


As the name suggests this function provides information and instructions to the user of the application.

The code for the help() function could be as follows:

# Help screen.
def help():
helptext = appuifw.Text()
helptext.set(u"Scheduler:\nHere you can manage the locations and the reminders associated with those locations.")
appuifw.app.body = helptext
appuifw.app.quit = main

The help text can be more descriptive and instructions may be added to the sample statement.

Also a text file containing the instructions for using the application could be opened through this functions.


This is the main tracker function, however only background_handler() is called from the menu in the main function.

We use the tracker to assign the current cellid to variable curr_cellid or the last cellid variable, last_cellid.

The appswitch module is used in this function. We can use it to trigger the application to foreground and background as follows:


The appswitch extension could be downloaded here.

The code for the tracker() could be as follows:

# The main tracker function.
def tracker():
(mcc, mnc, lac, cellid) = location.gsm_location()
while track == 1:
(mcc, mnc, lac, cellid) = location.gsm_location()
curr_cellid = cellid
if not curr_cellid == last_cellid:
reminderscnt = len(reminders)
tracker_log = ""
curr_date = time.strftime("%d/%m/%Y")
for i in range(reminderscnt):
j = str(i)
reminder_date = time.strftime("%d/%m/%Y", time.gmtime(float(reminders[j]['date']) + 5400))
if str(reminders[j]['cell']) == str(curr_cellid) and curr_date == reminder_date:
tracker_log += j + ": (" + str(curr_cellid) + ") " + str(reminders[j]['desc']) + "\n"
appuifw.query(unicode(str(reminders[j]['desc'])), "query")
last_cellid = curr_cellid

Here we use e32.ao_sleep(5) so that the function repeats, (if recursive ) every 5 seconds. The time can be adjusted according to the needs of the developer.

Other option is the timers, instead for sleep function.

The sample code for timers could be found here. sleep is used here to avoid complexity.


The background_handler() is called from the main menu when "Start Tracking" is selected.

A menu including "Stop Tracker" and "Help" is created using appuifw.app.menu function.

appswitch is used to set the application is background using switch_to_background(app_name) method. The appswitch extension could be downloaded here.

The code for background_handler() could be as follows.

def background_handler():
global track
if not track or track == 0:
track = 1
appuifw.app.menu = [(u"Help", help),
(u"Stop Tracker", background_handler)]
elif track == 1:
track = 0

Calling the methods

The defined methods need to be called in a proper sequence, and some variables need to be populated.

The file handler for alarm or alert could be set as:

file_handler_alert = "Path to the sound file"

The sound file should be .wav, .mp3, .acc (supported to be played by the specific Mobile device)

Sequence of initializing and calling methods:

# Populate cellids and geo dictionary and loclist list.
cellids = {}
geo = {}
track = 0
# Populate reminder and remsdesc dictionary.
reminders = {}
remindersdesc = {}
# temporary cell id list for testing without network requirement.
cellidlist = [1563, 1671, 1523, 1111, 1111, 1671]
S = audio.Sound.open(file_handler_alert)
# Start program.
app_lock = e32.Ao_lock()
appuifw.app.title = u'Geo-Sheduler'



Screenshot0016.jpg Screenshot0017.jpg Screenshot0018.jpg

Screenshot0019.jpg Screenshot0020.jpg Screenshot0021.jpg

Screenshot0022.jpg Screenshot0023x.jpg Screenshot0024x.jpg



We have concluded the series of the articles on "How do develop a Geo-scheduler application"

If you have been following the series, you may now be able to make location based application - logic, design and UI - Using the template from the geo-scheduler application

The links to the previous articles in the series could be found below.

Go to

81 page views in the last 30 days.