作者fake01 (code)
看板AndroidDev
标题[问题] 使用method问题
时间Tue Jul 24 15:36:48 2012
想使用别的Java档中的method
public 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) {
longitude = location.getLongitude();
latitude = location.getLatitude();
}
else {
Toast.makeText(this, "无法定位座标", Toast.LENGTH_LONG).show();
}
}
而我在想要呼叫method 的地方写
public LatitudeAndLongitude LatitudeAndLongitude;
LatitudeAndLongitude = new LatitudeAndLongitude();
LatitudeAndLongitude.locationServiceInitial();
在实机跑的时候,就会程式崩溃,请问该如何解决?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.138.152.7
1F:推 asilzheng:你的LatitudeAndLongitude是class name还是member???? 07/24 18:26
2F:推 kewang:真的觉得原po应该先去买本java书好好k比较好 07/24 22:01
3F:→ fake01:Class name 感谢 指教 07/24 23:58