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 (
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 :)
I’m trampled by your contents carry on the wonderful work.hike messenger 3.8.9
ReplyDelete