Geocoding and Reverse Geocoding in Android

by Krishnaraj Varma on July 4, 2010

Download source code of the article.

Geocoding is the process of finding geographic location from location name, zip codes, etc… Reverse Geocoding is the process of finding location name and other information from geographic location. In Android there is a class Geocoder which handles Geocoding and Reverse Geocoding. This class has three methods: getFromLocation, getFromLocationName and a variant of getFromLocationName.

The method getFromLocation is used to reverse geocode and the method getFromLocationName is used to geocode. The getFromLocation method accepts 3 parameters: latitude, longitude and maximum number of results to return.

There are 2 variants of the method getFromLocationName. Both accept location name and maximum number of results to return. The first variant accepts additional four parameters. These are the longitude and latitude of the bounding rectangle for the search results. If you specify these parameters, the Geocoder will only search within the bounding rectangle, i.e. the results outside the bounding rectangle will not be included in the results.

These functions return a list of Address class which represents the result of the query.

The sample provided is a simple one to demonstrate the use of this class, hope this will help you to start geocoding.

{ 9 comments }

Vibrating the phone in Android

by Krishnaraj Varma on June 27, 2010

To vibrate the phone we use Vibrator class. This is a system service so we don’t instantiate but use getSystemService to get the instance of the class. The following code snippet vibrates the phone for a period of time.

Vibrator vibrator = (Vibrator)getSystemService(VIBRATOR_SERVICE);
long[] pattern = {0,1000,2000,3000};

vibrator.vibrate(pattern, -1);

The vibrate method accepts the pattern to vibrate and an index of the pattern to start repeating. If we don’t want to repeat pass -1. If we just want to vibrate for a period of time with default pattern then we can use the following variant of the vibrate method which vibrate for 1 second.

vibrator.vibrate(1000);

{ 0 comments }

Using Status Bar Notification in Android

by Krishnaraj Varma on June 27, 2010

Download source code of the article.

This is an example of using Status Bar Notification in Android. Notifications are using in Android to notify the user of events. The classes Notification and NotificationManager is used create notification. NotificationManager is a system service. We get the instance using getSystemService. The following code snippet creates a default notification:

NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);

int icon = R.drawable.icon;
CharSequence text = "Notification Text";
CharSequence contentTitle = "Notification Title";
CharSequence contentText = "Sample notification text.";
long when = System.currentTimeMillis();

Intent intent = new Intent(this, NotificationViewer.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, 0);

Notification notification = new Notification(icon,text,when);

notification.setLatestEventInfo(this, contentTitle, contentText, contentIntent);

notificationManager.notify(Constants.NOTIFICATION_ID, notification);

For creating a status bar notification, we create an instance of Notification class and uses notify method of NotificationManager to add the trigger the notification. Here the Notification class is created with three parameters, icon to display, notification text to ticker and the time at which the notification is displayed. Then we set the notification title, notification text and the Pending Intent to launch when the user clicks on the notification.

The notify method of the NotificationManager is used to trigger the notification. This will add the notification to the status bar area. When the use pulls down the status bar the notification title, text and icon will be shown.

Vibrating the phone

If we want to vibrate the phone when the notification is displayed, then we can set the vibration pattern or use the flag to use the default vibration. Following code snippet sets the default vibration.

notification.defaults |= Notification.DEFAULT_VIBRATE;

To vibrate we set the vibrate member of the notification class. This is an array of long values; first element is the millisecond to wait before start, second is the length of the first vibration, third is the next millisecond to stay off and forth is the next millisecond to stay on and so on. The pattern can be as long as we like. Following code snippet sets the vibration:

long[] vibrate = {0,100,200,300};
notification.vibrate = vibrate;
Flashing the LED If we want to flash the LED then we can use the defaults flag to DEFAULT_LIGHTS. Following code snippets adds the default LED flash.
notification.defaults |= Notification.DEFAULT_LIGHTS;

To use our own color pattern, set the ledARGB, ledOffMS, and ledOnMS and add the FLAG_SHOW_LIGHTS to the flag field. Following code snippets add a custom color pattern.

notification.ledARGB = Color.RED;
notification.ledOffMS = 300;
notification.ledOnMS = 300; 

Using a custom view to display notification.

In the above example the notification is displayed in a default view. If we want to use our own custom view to display notification, then we can define the custom layout using the RemoteView. For this we create an instance of RemoteView and set the contentView field of the Notification class.

Note: If we are setting the contentView then we should set the contentIntent field also, otherwise an exception will occur.

The RemoteView provides helper methods to set the values of the layout items like setTextViewText, setProgressBar, setImageViewResource, etc…

The example provided here is a simple one to display default and custom view notifications. The custom view defines an image view, text view and a progress bar. Once the custom notification is triggered, the application creates a thread to start the progress bar update. This is a simple method display the progress indicator. Real world scenarios require more complicated method.

{ 0 comments }

Download source code of this article.

My previous article explains how to use the TelephonyManager. One of the important functionality of TelephonyManager is listening to different phone state events. The method listen(PhoneStateListener listener, int events) is used to add a phone state listener. The first parameter is the PhoneStateListener class and the second parameter is the int value contains various phone state to listen. We can listen for following events:

PhoneStateListener.LISTEN_SIGNAL_STRENGTH
PhoneStateListener.LISTEN_DATA_ACTIVITY
PhoneStateListener.LISTEN_CELL_LOCATION
PhoneStateListener.LISTEN_CALL_STATE
PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR
PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
PhoneStateListener.LISTEN_SERVICE_STATE

The PhoneStateListener has following methods:

void onCallForwardingIndicatorChanged(boolean cfi)
void onCallStateChanged(int state, String incomingNumber)
void onCellLocationChanged(CellLocation location)
void onDataActivity(int direction)
void onDataConnectionStateChanged(int state)
void onDataConnectionStateChanged(int state, int networkType)
void onMessageWaitingIndicatorChanged(boolean mwi)
void onServiceStateChanged(ServiceState serviceState)
void onSignalStrengthChanged(int asu)
void onSignalStrengthsChanged(SignalStrength signalStrength)

The PhoneStateListener.LISTEN_SIGNAL_STRENGTH events invoke the onSignalStrengthChanged(int asu) method. This method requires the permission READ_PHONE_STATE. The method has one integer parameter which is the signal strength value. This value can be in the range 0-31. This function is deprecated in Android Version 2.0 and above. Above 2.0 we should use the onSignalStrengthsChanged(SignalStrength signalStrength) method. Only one parameter is there and it SignalStrenth class. The SignalStrength class has different following methods:

int describeContents()
boolean equals(Object o)
int getCdmaDbm()
int getCdmaEcio()
int getEvdoDbm()
int getEvdoEcio()
int getEvdoSnr()
int getGsmBitErrorRate()
int getGsmSignalStrength()

The function names describes its purpose.

The PhoneStateListener.LISTEN_DATA_CONNECTION_STATE event invokes the methods onDataConnectionStateChanged(int state) and onDataConnectionStateChanged(int state, int networkType). Both these are invoked. The first parameter is the connection state and can be one of the following values:

TelephonyManager.DATA_DISCONNECTED
TelephonyManager.DATA_CONNECTING
TelephonyManager.DATA_CONNECTED
TelephonyManager.DATA_SUSPENDED

The PhoneStateListener.LISTEN_DATA_ACTIVITY event invokes the method onDataActivity(int direction). This method requires the permission READ_PHONE_STATE. The direction parameter can be one of the following values:

TelephonyManager.DATA_ACTIVITY_IN
TelephonyManager.DATA_ACTIVITY_OUT
TelephonyManager.DATA_ACTIVITY_INOUT
TelephonyManager.DATA_ACTIVITY_NONE

The PhoneStateListener.LISTEN_CALL_STATE event invokes the method onCallStateChanged(int state, String incomingNumber). This method requires the permission READ_PHONE_STATE. The state parameter can be one of the following values:

TelephonyManager.CALL_STATE_IDLE
TelephonyManager.CALL_STATE_RINGING
TelephonyManager.CALL_STATE_OFFHOOK

The incomingNumber parameter contains the incoming number if the state is TelephonyManager.CALL_STATE_RINGING.

The PhoneStateListener.LISTEN_CELL_LOCATION event invokes the method onCellLocationChanged(CellLocation location) method. This method requires the permission ACCESS_COARSE_LOCATION. This will be an instance of GsmCellLocation class. GsmCellLocation class is explained in my previous article.

The PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR event invokes the method onCallForwardingIndicatorChanged(boolean cfi) method. This method requires the permission READ_PHONE_STATE. The boolean parameter cgi indicates whether the current call is forwarding or not.

The PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR event invokes the method onMessageWaitingIndicatorChanged(boolean mwi). This method requires the permission READ_PHONE_STATE. The boolean parameter mwi indicates whether an incoming message is waiting for user attention or not.

The PhoneStateListener.LISTEN_SERVICE_STATE event invokes the method onServiceStateChanged(ServiceState serviceState). The parameter is an instance of ServiceState class. The ServiceState class has methods to retrieve operator name in short alphanumeric format, operator name in short long format, operator id, etc…

To un-register a listener we use the method listen with event parameter set to LISTEN_NONE.

The sample provided is same for this and the previous article. Hope this article helps to to get started with PhoneStateListener.

{ 3 comments }

Using Android TelephonyManager

by Krishnaraj Varma on June 13, 2010

Download source code of this article.

Android TelephonyManager provides information about the android telephony system. To use the TelephonyManager first get the instance of the Telephony Service by calling Context.getSystemService(TELEPHONY_SERVICE). This telephony service can be used to retrieve Call State, Cell Location, Operator Name, etc… as well as to listen to the various telephony events. Following are some of the important information we can get from TelephonyManager:

Cell Location

The getCellLocation method is used to get the Cell Location of the device. This method returns an instance of GsmCellLocation class. The getCid() and getLac() methods of this class can used to retrieve the Cell ID and LAC of the device. This method requires the permission ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION. Following code snippet shows how to retrieve the Cell ID and LAC.

TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
GsmCellLocation loc = (GsmCellLocation) tm.getCellLocation();

int cellid = loc.getCid();
int lac = loc.getLac();

IMEI/MEID

The getDeviceId() method is used to get the IMEI/MEID of the device. If the device is a GSM device then IMEI will be returned and if the device is a CDMA device then MEID will be returned. This device id can be used to uniquely identify the device. This method requires the permission READ_PHONE_STATE. Following code snippet retrieve the device id.

String deviceid = tm.getDeviceId();

Device Phone Number

The getLine1Number() method returns the device phone number (MSISDN). This method requires the permission READ_PHONE_STATE. Following code retrieve the device phone number:

String phonenumber = tm.getLine1Number();

Note: This function name not work prior to Android Version 2.0.

Network Name

The getNetworkOperatorName() method returns the registered network operator’s name, getNetworkOperator() method returns the MCC + MNC of the registered network operator and getNetworkCountryIso() returns the registered network operator’s country code. This information may not be available on CDMA devices. Following code snippets retrieves these details:

String operatorname = tm.getNetworkOperatorName();
String operatorcode = tm.getNetworkOperator();
String operatoriso = tm.getNetworkCountryIso();

SIM Card Infomarion

The getSimCountryIso() returns the SIM operator’s country code, getSimOperator() returns the SIM operator’s MNC + MCC number, getSimOperatorName() returns the SIM operator’s name and getSimSerialNumber() returns the SIM Serial Number. This method requires the permission READ_PHONE_STATE. Following code snippets reads the SIM Card information:

String simcountrycode = tm.getSimCountryIso();
String simoperator = tm.getSimOperatorName();
String simserialno = tm.getSimSerialNumber();

Network Type

The getNetworkType() returns the type of the network available in the device. This method returns one of the following values:

TelephonyManager.NETWORK_TYPE_UNKNOWN
TelephonyManager.NETWORK_TYPE_GPRS
TelephonyManager.NETWORK_TYPE_EDGE
TelephonyManager.NETWORK_TYPE_UMTS

Phone Type

The getPhoneType() returns the device type. This method returns one of the following values:

TelephonyManager.PHONE_TYPE_NONE
TelephonyManager.PHONE_TYPE_GSM
TelephonyManager.PHONE_TYPE_CDMA

Subscriber ID

getSubscriberId() return the subscriber id of the device. This is IMSI if the device is a GSM device. If unavailable the function returns null. This function requires the permission READ_PHONE_STATE.

Neighboring Cell Information

The getNeighboringCellInfo() function returns a list of NeighboringCellInfo class which represents the neighboring cell information if available otherwise the function returns null. This function returns the permission ACCESS_COARSE_UPDATES. Following code snippet returns the this information:

List cellinfo = tm.getNeighboringCellInfo();

for(NeighboringCellInfo info: cellinfo){
    cellid = info.getCid();
    rssi = info.getRssi();
}
Note: I never got this working. I search a lot but I didn't get any useful information why it is not returning value. Also when I ran this on a Android Version 1.6 Developer Phone I got a Unknown permission android.permission.ACCESS_COARSE_UPDATES. Please let me know if you get this working. Listening to Phone State Change
The listen() method is used to register a phone state listener. It accepts a PhoneStateListener instance and an int value specifying what are the events to listen. Following are the events we can listen:
PhoneStateListener.LISTEN_SIGNAL_STRENGTH
PhoneStateListener.LISTEN_DATA_ACTIVITY
PhoneStateListener.LISTEN_CELL_LOCATION
PhoneStateListener.LISTEN_CALL_STATE
PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR
PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
PhoneStateListener.LISTEN_SERVICE_STATE

PhoneStateListener class has following method:

void onCallForwardingIndicatorChanged(boolean cfi)
void onCallStateChanged(int state, String incomingNumber)
void onCellLocationChanged(CellLocation location)
void onDataActivity(int direction)
void onDataConnectionStateChanged(int state)
void onDataConnectionStateChanged(int state, int networkType)
void onMessageWaitingIndicatorChanged(boolean mwi)
void onServiceStateChanged(ServiceState serviceState)
void onSignalStrengthChanged(int asu)
void onSignalStrengthsChanged(SignalStrength signalStrength)

Listening to phone state requires a separate article to describe, so this will be explained in my next post.

Following table describes important functions and its permission:

Function Description
getCellLocation() Returns the the Cell Location of the device
ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION
getDeviceId() Returns the IMEI/MEID of the device. If the device is a GSM device
then IMEI will be returned and if the device is a CDMA device then MEID
will be returned
READ_PHONE_STATE
getLine1Number() Returns the device phone number (MSISDN)
READ_PHONE_STATE
getNetworkOperatorName() Returns the registered network operator's name
getNetworkOperator() Returns the MCC + MNC of the registered network operator
getNetworkCountryIso() Returns the registered network operator's country code
getSimCountryIso() Returns the SIM operator's country code
READ_PHONE_STATE
getSimOperator() Returns the SIM operator's MNC + MCC number
READ_PHONE_STATE
getSimOperatorName() Returns the SIM operator's name
READ_PHONE_STATE
getSimSerialNumber() Returns the SIM Serial Number
READ_PHONE_STATE
getNetworkType() Returns the type of the network available in the device. This will be
one of the following values:

TelephonyManager.NETWORK_TYPE_UNKNOWN

TelephonyManager.NETWORK_TYPE_GPRS

TelephonyManager.NETWORK_TYPE_EDGE

TelephonyManager.NETWORK_TYPE_UMTS


READ_PHONE_STATE

getPhoneType() Returns the device type. This will be one of the following values:

TelephonyManager.PHONE_TYPE_NONE

TelephonyManager.PHONE_TYPE_GSM

TelephonyManager.PHONE_TYPE_CDMA


READ_PHONE_STATE

getSubscriberId() Return the subscriber id (IMSI) of the device
READ_PHONE_STATE
getNeighboringCellInfo() Returns a list of NeighboringCellInfo class which represents the
neighboring cell information if available otherwise the function
returns null
ACCESS_COARSE_UPDATES

{ 3 comments }

Download source code of the article.

Programming GPS on Android is fairly simple. In Android to get GPS updates you simply initiate LocationManager class, find a GPS provider and request for updates. To initiate LocationManager manager class you call getSystemService method of the Activity class. LocationManager class provides the location service and periodic updates of the geo location. Once you get the LocationManager class next step is to find out the best GPS provider available on the system which satisfies your criteria.

To get the provider you specify different criteria you need like accuracy, altitude, bearing, etc… For this we use the Criteria class. Following is a sample criterion:

final Criteria criteria = new Criteria();

criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setCostAllowed(true);
criteria.setPowerRequirement(Criteria.POWER_LOW);

To find out whether a GPS provider best matches the given criteria we use the getBestProvider method of the LocationManager class. This manager will return name of the location provider if it is available. Otherwise the criteria are modified/loosened in the following order:

    Power requirement
    Accuracy
    Bearing
    Speed and
    Altitude

Once we get the provider, we request updates using requestLocationUpdates method. If you only need current location and not need to receive continuous location update you can use getLastKnownLocation method to get the last known location of the device.

To request continuous location we device a variable of LocationListener class and override onLocationChanged method. LocationManager will call this method and pass a Location class whenever there is a change in the device geographic location.

To calculate the distance between two geographic locations, the Location class provides a static method distanceBetween. This method calculates the distance between two geographic locations in meters and returns the result in a float array you pass. You can pass an array of length 1, 2 or 3.

The first element (array[0]) will be the distance in meter. If the array has 2 or more elements the second element (array[1]) will hold the initial bearing value. If the array has 3 or more elements then the third element (array[2]) will hold the final bearing value.

To stop receiving the location updates you call the removeUpdates method of the LocationManager class.

The given sample initializes the LocationManager and requests for periodic location updates. When you press the “Start Measuring” button it calculates the distance between that position and your current position. Hope this will help you to start GPS programming on Android.

{ 1 comment }

Using Windows Mobile State and Notification Broker

by Krishnaraj Varma on September 20, 2009

Download [download id="5"]

Windows Mobile State and Notification Broker is a mechanism which provides storing system and application information in registry and send notifications whenever these values changes. An application registers for a particular event and the State and Notification Broker notifies the client application whenever the event occurs. For example an application wants to get notified when the Windows Media Player start playing a media or when the cellular signal level changes.

The State and Notification Broker mechanism works by monitoring any registry key and whenever the key changes send notification to all the registered clients. The Windows Mobile system provides many notifications. The header file SNAPI.H provides the definitions of the registry keys, its path and bitmask for all the notifications the system provides. The general categories of notifications are:

    System state information
    Message information
    Tasks and appointment information
    Windows Media Player information
    Phone information
    Connection information

Besides these notifications, an application can create its own notification. In this case the application is a provider which provides state notifications. To do this the application creates a registry key and changes this key whenever the state is changes. The State and Notification Broker will notify all the client applications that registered for this event.

A client application does the following steps to get notified about an event:

    A client Register for the notification using RegistryNotifyApp, RegistryNotifyWindow, RegistryNotifyCallback or RegistryNotifyMsgQueue API.
    When the notification arrives, the client application reads the specified registry key to get the necessary information
    When the client application no longer needs the notification, close the notification using RegistryCloseNotification.

A provider application does these steps to provide notification of the state change:

    A provider application creates a registry key and stores the state information
    When a change occurs, the provider application changes this information
    The State and Notification Broker notifies all the clients when the change occurs

The State and Notification Broker supports the following notification types:

Transient: In this, the notifications are only valid when the application is running. The request is closed when the application exits or the device is reset.

Persistent: In persistent type, the notification is remains valid even after the application exits or the device is reset.

There are four modes of notifications in State and Notification Broker, they are;

Application Activation: In this mode, the State and Notification Broker starts the application if it is not running already. This mode applies to the persistent notification type.

Window Message: In this mode, the State and Notification Broker sends the specified window message to the application window. This mode applies to the transient notification type.

Message Queue: In this mode, the Broker sends the message to the specified Message Queue. This mode applies to the transient notification type.

Callback Function: In this mode, the Broker calls the specified callback function when the state change occurs. This mode applies to the transient notification type.

Besides these the State and Notification Broker also support Conditional Notification and Batch Notification. In Conditional Notification, an application can specify to send notification only when the state property is changed to a particular value. This way an application can reduce the number of notification sends to the application. In this the system checks the state property value and send the notification only if the property value matches the specified value.

In Batch Notification, an application can tell the system how frequently the notification has to send. Here you can specify maximum idle time before sending the notification. Whenever the change occurs, the system waits the specified idle time before sending the notification. If the value changes during this time, the system resets the idle time and waits another idle time. But this may leads to infinite wait, to prevent this you can specify maximum wait time. The system either waits for the maximum wait time or waits for the value to get settled.

As I stated before there are many notifications provides by the system by default. For a detailed explanation either refer to the SNAPI.H header file or follow this link: http://msdn.microsoft.com/en-us/library/aa455750.aspx

In Native Mode, the header file REGEXT.H contains the function to register and close the notifications. In Managed Mode, it is exposed via the Microsoft.WindowsMobile.Status namespace (Microsoft.WindowsMobile.Status.dll assembly).

In Native Mode, an application uses any of the following function to register for the notification.

HRESULT WINAPI RegistryNotifyApp(HKEY hKey, LPCTSTR pszSubKey, LPCTSTR pszValueName, LPCTSTR pszName, LPCTSTR pszApp, LPCTSTR pszClass, LPCTSTR pszWindow, UINT msg, DWORD dwFlags, NOTIFICATIONCONDITION* pCondition);

HRESULT WINAPI RegistryNotifyWindow(  HKEY hKey, LPCTSTR pszSubKey, LPCTSTR pszValueName, HWND hWnd, UINT msg, DWORD dwUserData, NOTIFICATIONCONDITION* pCondition, HREGNOTIFY* phNotify);

HRESULT WINAPI RegistryNotifyWindow(HKEY hKey,LPCTSTR pszSubKey, LPCTSTR pszValueName, HWND hWnd, UINT msg, DWORD dwUserData, NOTIFICATIONCONDITION* pCondition, HREGNOTIFY* phNotify);

HRESULT WINAPI RegistryNotifyMsgQueue(HKEY hKey, LPCTSTR pszSubKey, LPCTSTR pszValueName, LPCTSTR pszMsgQueue, DWORD dwUserData, NOTIFICATIONCONDITION* pCondition, HREGNOTIFY* phNotify);

The RegistryNotifyApp API is used to register for persistent notification mode. The parameters are:

hKey Handle to the opened key or the root key
pszSubKey Name of the sub key, this can be null
pszValueName Name of the value in which state is stored
pszName A unique user defined string that represents the
notification. Note that it should be unique, you can try something like ApplicationName.
pszApp Complete path of the executable to be start when the event occurs
pszClass Class name of the window that receives the notification message,this can be NULL
pszWindow Name of the window that receives the notification message, this can be NULL
msg Message to be send to the window. If both pszClass and pszWindow are null, the system will just start the application and will not send the
message.
dwFlags Notification flags, this should be 0 or RNAF_NONAMEONCMDLINE. If 0 then system will send the pszName as a command
line
pCondition A pointer to the NOTIFICATIONCONDITION structure. Using
this structure you can specify the conditions to be checked before sending
the notification. See Conditional Notification

The first three parameters are common for all the APIs. The other parameters change according the API.

When the notification receives, client the application can use RegistryGetString or RegistryGetDWORD to read values from the key. Whenever the application finished using the notification, application should close the notification by using the API RegistryCloseNotification or RegistryStopNotification.

To create a notification provider, an application has to create a registry key and change the value of the registry key whenever the state is changed. The system will notify all the client applications about the change.

There are two samples provided, one is uses transient mode and other uses persistent mode. These are very simple ones to get started with the State and Notification Broker mechanism. Hope this will help you to get started.

{ 0 comments }

A very simple TAPI dialer for Windows Mobile

by Krishnaraj Varma on September 20, 2009

Download [download id="4"]

Here is a very simple TAPI dialer for Windows Mobile as requested by one of my friend. I hope this will help beginners to start with TAPI on Windows Mobile. Following are the steps to dial a number using TAPI:

  • Initialize TAPI
  • Negotiate the TAPI version
  • Open the cellular line
  • Dial the number using lineMakeCall
  • To drop the initiated call use lineDrop
  • { 0 comments }

    Getting Signal Strength using TAPI and RIL

    by Krishnaraj Varma on September 6, 2009

    Download [download id="2"]
    Download [download id="3"]

    In Windows Mobile, we can retrieve signal strength in two ways, one using TAPI and other using RIL. The TAPI function lineGetLineDevStatus is used to retrieve the signal strength of the current line. This function returns the details in LINEDEVSTATUS variable length structure. The dwSignalLevel member contains the signal strength in the range 0×00000000 to 0x0000FFFF.

    The other method is to use the RIL function RIL_GetSignalQuality. This functon returns the signal strength in RILSIGNALQUALITY structure. The member nSignalStrength contains the signal strength. This link explains how to calculate the signal strength from the RILSIGNALQUALITY structure members.

    { 0 comments }

    Getting message configuration programmatically using RIL

    by Krishnaraj Varma on August 24, 2009

    Download the [download id="1"]

    Here is a sample application to get the messaging configuration using Radio Interface Layer (RIL). The RIL function RIL_GetMsgConfig is used to get the messaging configuration. This function returns the configuration in RILMSGCONFIG structure.

    { 0 comments }