看板 AndroidDev 關於我們 聯絡資訊
想使用別的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
asilzheng:你的LatitudeAndLongitude是class name還是member???? 07/24 18:26
kewang:真的覺得原po應該先去買本java書好好k比較好 07/24 22:01
fake01:Class name 感謝 指教 07/24 23:58