读书人

DDMS发送中纬度模拟器收不到

发布时间: 2012-08-02 11:35:25 作者: rapoo

DDMS发送经纬度模拟器收不到
使用DDMS想模拟器发送经纬度 模拟器就是收不到 代码如下 感觉没有什么问题啊
是不是版本的问题啊???
public class MainActivity extends Activity {

private Button button = null;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button = (Button)findViewById(R.id.locationButtonId);
button.setOnClickListener(new ButtonListener());
}


private class ButtonListener implements OnClickListener{

@Override
public void onClick(View arg0) {
LocationManager locationManager = (LocationManager)MainActivity.this.getSystemService(Context.LOCATION_SERVICE);
//1.定义当前说使用的Location Provider
System.out.println(">>>>>>>>>>>>>>>>");
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new TestLocationListener());
}
}

private class TestLocationListener implements LocationListener{

@Override
public void onLocationChanged(Location location) {
System.out.println(location.getLongitude());//经度
System.out.println(location.getLatitude());//维度
}

@Override
public void onProviderDisabled(String provider) {

}

@Override
public void onProviderEnabled(String provider) {

}

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {

}
}

读书人网 >移动开发

热点推荐