Class project & thesis work - trying to pull information from CDMA Cell, specifically by using the getBaseStationLatitude() & getBaseStationLongitude(). The value being returned is the MAX_VALUE (2147483647) - I'm not receiving actual lat/longs. getBaseStationID(), getNetworkID() & getSystemID() are returning valid id's. I've tested this in 2 separate cells with no luck. My code is posted below. Both ACCESS_FINE_LOCATION & ACCESS_COURSE_LOCATION are added to manifest. Testing done on Droid, Android 2.2.2.
Questions - Has anyone run into same problems? Am I missing something in the code? Where are these values stored and issued at (e.g. are these coordinates assigned at the base station, and constantly being transmitted to mobile device)?
Code:
package xXx.edu.com;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.telephony.cdma.CdmaCellLocation;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
public class CDMAData extends Activity implements OnClickListener{
CdmaCellLocation location;
int cellID, lat, lon, netID, sysID;
private Context context;
Button getDataBtn;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
context = (Context) this;
setContentView(R.layout.cid);
setConnections();
}
private void setConnections() {
getDataBtn = (Button) this.findViewById(R.id.getID);
getDataBtn.setOnClickListener(this);
}
public void onClick(View v) {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
location = (CdmaCellLocation) tm.getCellLocation();
cellID = location.getBaseStationId();
lat = location.getBaseStationLatitude();
lon = location.getBaseStationLongitude();
netID = location.getNetworkId();
sysID = location.getSystemId();
TextView myView1 = (TextView) findViewById(R.id.bsID);
myView1.setText("" + cellID);
TextView myView2 = (TextView) findViewById(R.id.bsLat);
myView2.setText("" + lat);
TextView myView3 = (TextView) findViewById(R.id.bsLon);
myView3.setText("" + lon);
TextView myView4 = (TextView) findViewById(R.id.netID);
myView4.setText("" + netID);
TextView myView5 = (TextView) findViewById(R.id.sysID);
myView5.setText("" + sysID);
}
}