I wrote some code which basically spits out NMEA sentences. The code worked on froyo and did exactly what I wanted. Now However, when I got the gingerbread upgrade, it is no longer working. Has anyone else had this issue?
I'm using a Nexus One and will post some code later if you guys need it.
Thanks
Sorry, i was very busy lately. Here is the code finally:
public class GPSTest extends Activity {
TextView mTextView;
Button mStartButton, mStopButton;
LocationManager mLocationManager;
boolean isRegistered;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mTextView = (TextView) findViewById(R.id.mTextView);
mStartButton = (Button) findViewById(R.id.Button01);
mStopButton = (Button) findViewById(R.id.Button02);
mStartButton.setOnClick开发者_Go百科Listener(mButtonListener);
mStopButton.setOnClickListener(mButtonListener);
mLocationManager = (LocationManager) this.getSystemService(LOCATION_SERVICE);
}
void registerListeners(){
if(!isRegistered){
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0 , 0, mLocationListener);
mLocationManager.addNmeaListener(mListener);
isRegistered=true;
}
}
void deregisterListeners(){
if (isRegistered){
mLocationManager.removeUpdates(mLocationListener);
mLocationManager.removeNmeaListener(mListener);
isRegistered=false;
}
}
OnClickListener mButtonListener = new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (v==mStartButton){
registerListeners();
}else{
deregisterListeners();
}
}
};
@Override
protected void onPause(){
super.onPause();
deregisterListeners();
}
@Override
protected void onResume(){
super.onResume();
registerListeners();
}
NmeaListener mListener = new NmeaListener(){
@Override
public void onNmeaReceived(long timestamp, String nmea) {
// TODO Auto-generated method stub
mTextView.append("\n"+nmea);
}
};
LocationListener mLocationListener = new LocationListener(){
@Override
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
;
}
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
};
}
Documented bug in the post-Froyo implementations on some handsets (Nexus One I can confirm, Xoom anecdotally seems to be fine). Haven't heard from the folks using the Nexus S, but it sounds like they are fine.
See http://code.google.com/p/android/issues/detail?id=15500 for more detail.
Edit: trying to poke the folks at Google to see if some clarification can be found.
Edit 2: Oh yeah, verified that 2.2 works (HTC Incredible, Nexus One worked BEFORE the 2.3 update), but the same Nexus One no longer works after updating to 2.3.3.
精彩评论