Monday, October 09, 2006

Symbian On Frappr

Tuesday, August 22, 2006

Getting the Current Cell Id using Symbian S60 C++

What you need:
Series 60 SDK
Communicator 9200 SDK version 0.9 or higher
etel.h from Communicator 9200 SDK
etelbgsm.h from Communicator 9200 SDK

Instructions:
Copy etel.h and etelbgsm.h to the \Symbian\6.1\Series60\Epoc32\Include directory.

Link your app to gsmbas.lib and etel.lib.

Use this code:
 RBasicGsmPhone phone;
RTelServer server;

User::LeaveIfError( server.Connect() );
// load a phone profile
_LIT(KGsmModuleName, "phonetsy.tsy");
User::LeaveIfError( server.LoadPhoneModule( KGsmModuleName ) );

// initialize the phone object
RTelServer::TPhoneInfo info;
User::LeaveIfError( server.GetPhoneInfo( 0, info ) );
User::LeaveIfError( phone.Open( server, info.iName ) );

MBasicGsmPhoneNetwork::TCurrentNetworkInfo netinfo;
User::LeaveIfError( phone.GetCurrentNetworkInfo( netinfo ) );

Now you should be able to access the fields of
MBasicGsmPhoneNetwork::TCurrentNetworkInfo
which are
.iCellId
.iLocationAreaCode
.iNetworkInfo.iShortName

Once you have grabbed the info use this code to clean up:

phone.Close();
server.UnloadPhoneModule( KGsmModuleName );

server.Close();

All the code should work for the 6600 as well. You have the option of
just compiling with the 1.2 SDK or copying the headers to the 2.0 SDK .

Explore the other functions and data available through these objects as well. The headers should provide you with enough information to figure out what they are. Not all of them are completely implemented. According to a Forum Nokia post you can get to the information by:

  • ManufacturerId, Serial No: GetPhoneInfo()
  • BER, battery status: GetX - async version
  • Signal Strength: SignalStrengthNotification()

Use the NotifyChangeOfCurrentNetwork, so that works as well.

Thursday, August 10, 2006

About Screen Source Code for J2ME

Example source code for a typical About screen for your J2ME applications using alerts. It allows you to load an image color and greyscale of your logo and determines if the device is capable of displaying it in color otherwise displays the greyscale version. This class can easily be extended to have the text and image to be passed as parameters or in a resource file.


public class X extends javax.microedition.midlet.MIDlet
implements CommandListener, Runnable {


...
/** command about */
private Command cmdAbout = null;

...


...
cmdAbout = new Command("About", Command.HELP, 30);
anyForm.addCommand(cmdAbout);
...


public void commandAction(Command cmd, Displayable d) {
...

if (cmd == cmdAbout) {
About.showAbout(display);
}
....


/*
* @(#)About.java
* (C) Copyright Serkan Azmi. 2001
* All rights reserved
* The material(s) may be used and/or copied only with the written
* permission of Serkan Azmi. or in accordance with the terms and
* conditions stipulated in any agreement/contract under which
* the material(s) have been supplied.
*
* Created on 18 September 2001, 08:44
*/

import javax.microedition.lcdui.*;

/**
* Typical about box with a string and an image.
*/

public class About {

private static String copyright =
"\251 Serkan Azmi 2002";

private Displayable previous;
// the previous screen to go back to

private About() {};
// no instances

/**
* Put up the About box and when the use click ok return
* to the previous screen.
*/
public static void showAbout(Display display) {

Alert alert = new Alert("About");
alert.setTimeout(Alert.FOREVER);

if (display.numColors() > 2) {
String icon = (display.isColor()) ?
"/icons/NAME_OF_APPLICATION_ICON.png" :
"/icons/NAME_OF_APPLICATION_ICON_IN_GREYSCALE.png";

try {
Image image = Image.createImage(icon);
alert.setImage(image);
} catch (java.io.IOException x) {
// just don't append the image.
}
}
Runtime runtime = Runtime.getRuntime();

runtime.gc();
alert.setString(copyright);

display.setCurrent(alert);
}

}

Wednesday, August 09, 2006

Image Scroller for J2ME

Here is a class written for J2ME used for image scrolling on the screen.
Previously I posted this on Bulletproof Productions but here it is again.


/*
* ImageScroller.java
* (C) Copyright Serkan Azmi. 2001
* All rights reserved
* The material(s) may be used and/or copied only with the written
* permission of Serkan Azmi. or in accordance with the terms and
* conditions stipulated in any agreement/contract under which
* the material(s) have been supplied.
* Created on March 19, 2002, 8:08 PM
*/



/**
*
* @author serkan azmi
* @version 1.0
*/

import javax.microedition.lcdui.*;

/**
* This object is used to pan an Image.
*/

public class ImageScroller implements ActionListener {
private final Image m_image;
private final int m_screenWidth;
private final int m_screenHeight;
private final int m_imageWidth;
private final int m_imageHeight;

// values we need for movement
private int m_dx = 0;
private int m_dy = 0;
private int m_x;
private int m_y;
private int m_gameAction;
public static int m_factor;

/**
* The constructor registers the object with the updater,
* loads the image,and initialies all the constants.
*/
public ImageScroller(Canvas screen, Image image)
throws Exception {
ScrollScreen.register(this);
m_screenWidth = screen.getWidth();
m_screenHeight = screen.getHeight();
m_image = image;
m_imageWidth = m_image.getWidth();
m_imageHeight = m_image.getHeight();
m_x = (m_screenWidth - m_imageWidth)/2;
m_y = (m_screenHeight - m_imageHeight)/2;
m_factor = 1;
}

/**
* Draw the object on the screen.
*
* @param g The Graphics object to be used for rendering
* the Canvas.
*/
protected void paint(Graphics g) {
g.drawImage(m_image, m_x, m_y, Graphics.TOP|Graphics.LEFT);
}

/**
* Called when a game action is to be performed.
*/
public void performAction() {

System.out.println(""+m_factor);
switch(m_gameAction) {

case Canvas.UP:
if ((m_y+m_factor) < 0) {
m_y += m_factor;
}
else if (m_y < 0) {
m_y++;
}
break;
case Canvas.DOWN:
if((m_y-m_factor) > m_screenHeight-m_imageHeight) {
m_y -= m_factor;
}
else if (m_y > m_screenHeight-m_imageHeight) {
m_y--;
}
break;
case Canvas.LEFT:
if ((m_x+m_factor) < 0) {
m_x += m_factor;
}
else if (m_x < 0) {
m_x++;
}
break;
case Canvas.RIGHT:
if((m_x-m_factor) > m_screenWidth - m_imageWidth) {
m_x -= m_factor;
}
else if (m_x > m_screenWidth - m_imageWidth) {
m_x--;
}
break;
}
}

/**
* Called when a key is released. If the currently repeated
* key is the same as the one that is to be stopped then stop;
* otherwise ignore it, we must be repeating a different key.
*
* @param gameAction The game action that was pressed.
*/
protected void keyReleased(int gameAction) {
if (gameAction == m_gameAction) {
m_gameAction = 0;
}
}

/**
* Called when a key is pressed. Initialises the game action
* member variable only for the appropriate keys.
*
* @param gameAction The game action that was pressed.
*/
protected void keyPressed(int gameAction) {
switch (gameAction) {
case Canvas.LEFT:
case Canvas.RIGHT:
case Canvas.UP:
case Canvas.DOWN:
m_gameAction = gameAction;
break;
}
}


/**
* Called when a key is pressed. Initialises the game action
* member variable only for the appropriate keys.
*/
protected void keyRepeated() {
switch (m_gameAction) {
case Canvas.LEFT:
case Canvas.RIGHT:
case Canvas.UP:
case Canvas.DOWN:
m_gameAction = m_gameAction;
break;
}
}


/**
* Called when the pointer is pressed.
*


* This method is for devices with pointers (PDAs).
*
* @param x The horizontal location where the pointer was
* released (relative to the Canvas).
* @param y The vertical location where the pointer was
* released (relative to the Canvas).
*/
protected void pointerPressed(int x, int y) {
m_dx = x;
m_dy = y;
}

/**
* Called when the pointer is dragged.
*


* This method is for devices with pointers (PDAs).
*
* @param x The horizontal location where the pointer was
* released (relative to the Canvas).
* @param y The vertical location where the pointer was
* released (relative to the Canvas).
*/
protected void pointerDragged(int x, int y) {
m_y += y - m_dy;
m_x += x - m_dx;
m_dx = x;
m_dy = y;

if (m_y > 0) {
m_y = 0;
}
else if (m_y < m_screenHeight - m_imageHeight) {
m_y = m_screenHeight - m_imageHeight;
}

if (m_x > 0) {
m_x = 0;
}
else if (m_x < m_screenWidth - m_imageWidth) {
m_x = m_screenWidth - m_imageWidth;
}
}
}

Bulletproof Mobile

The time is now! Mobile technology is to sky rocket with the consumer base forever upgrading their mobile phones. Java-enabled phones together with Symbian OS phones make life and business much easier. Download the Midlet Development Kit and Symbian SDK and get started. Unleash your website to the wireless network. Deliver real time content to your clients via mobile.