Quantcast
Channel: iT邦幫忙
Viewing all articles
Browse latest Browse all 15645

java 私有方法運用

$
0
0
我要在stationListSetup 這個方法裡使用到
getLocation方法裡的
變數 lonnxx,lonnyy
要怎麼用??

private void locationServiceInitial() {
lms = (LocationManager) getSystemService(LOCATION_SERVICE);
Criteria criteria = new Criteria();
bestProvider = lms.getBestProvider(criteria, true);
Location location = lms.getLastKnownLocation(bestProvider);
getLocation(location);
}

private void getLocation(Location location) {
if (location != null) {
// TextView lonxx_txt = (TextView) findViewById(R.id.textxx);
// TextView lonyy_txt = (TextView) findViewById(R.id.textyy);
Double lonnxx = location.getLongitude();
Double lonnyy = location.getLatitude();

// lonxx_txt.setText(String.valueOf(lonnxx));
// lonyy_txt.setText(String.valueOf(lonnyy));
} else {
Toast.makeText(this, "無法定位座標", Toast.LENGTH_LONG).show();
}
}

public void stationListSetup() {

}

Viewing all articles
Browse latest Browse all 15645

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>