Pages

Hello geeks !!

Welcome.

This blog gives you several interesting information related to application development for smartphones such as Windows Mobile, iPhone, Android.

You may find pieces of code that might be of help to understand the concept that is being explained.

Please feel free to post back your questions, comments and suggestions.



Tuesday, December 8, 2009

Alternative to GPS using Radio Interface Layer (RIL)

GPS receivers are not available on all devices.

I wanted a work around to detect the location or user's country.

By digging in, I found the RIL (Radio Interface Layer) API.

You can find the RIL API and documentation here

The RIL is an interface between the radio hardware on the device and the system software.
The application can use the RIL API to interact with the radio hardware.

So what to do ?

For identifying the location, the RIL exposes a function called 'GetCellTowerInfo'.

You can find some RIL wrapper classes on the web which does the RIL low level programming and gives an easy interface for the application programming.

The GetCellTowerInfo function, returns a value that is in the following format.

         Cell ID - Location Area Code - Mobile Country Code

The CellID is the Cell Tower ID or the ID of the base station of the mobile network service provider.
The Location Area Code - The LAC uniquely identifies a particular location within a PLMN (Public Land Mobile Network)
The Mobile Country Code - The MCC is the code which identifies the country.




This is basically enough for identifying the country.


You can have the database of MCC in your application or your server where you can look up with the MCC.,


You can find the list of Mobile Country Codes here in Wikipedia.


Similarly you need to maintain a database of the LAC and Cell ID to identify the location more precisely.
But in this case, you might have to tie up with your service provider to get the database of the LAC and Cell IDs.


You can find some code for the RIL wrapper here


Hence, I'm not posting it again.


Happy finding :)

1 comment: