miriye
miriye

Reputation: 143

cell tower location for CDMA android phone using getBaseStationLatitude()/Longitude()

I'm developing an android app for CDMA phones that will gather the latitude/longitude of the cell tower they are connected to.

First: is this even possible?

Second: I've looked at previous posts where it says to simply add "CellLocation.requestLocationUpdate();" but it didn't have any effect. Here's the portion of code where I'm trying to retrieve the locations...

CdmaCellLocation CdmaLocation = (CdmaCellLocation)telephonyManager.getCellLocation();
int Longitude = CdmaLocation.getBaseStationLongitude();
int Latitude = CdmaLocation.getBaseStationLatitude();

Looking at the code for the CdmaCellLocation class reveals that those values are defaulted to Integer.MAX_VALUE, but how do you actually set the latitude and longitude?

Upvotes: 1

Views: 1031

Answers (1)

ralf htp
ralf htp

Reputation: 9412

you have to use PhoneStateListener with LISTEN_CELL_LOCATION and the corresponding callback function onCellLocationChanged(CellLocation) and LISTEN_CELL_INFO with callback function onCellInfoChanged(List) and possibly LISTEN_SIGNAL_STRENGHTS with callback onSignalStrengthsChanged(Signal Strength)

to quit getting change notification from the PhoneStateListener use LISTEN_NONE

http://www.truiton.com/2014/08/android-phonestatelistener-example/

https://developer.android.com/reference/android/telephony/PhoneStateListener.html

Upvotes: 1

Related Questions