[問題] 使用method問題

看板AndroidDev作者 (code)時間13年前 (2012/07/24 15:36), 編輯推噓2(201)
留言3則, 3人參與, 最新討論串1/1
想使用別的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

07/24 18:26, , 1F
你的LatitudeAndLongitude是class name還是member????
07/24 18:26, 1F

07/24 22:01, , 2F
真的覺得原po應該先去買本java書好好k比較好
07/24 22:01, 2F

07/24 23:58, , 3F
Class name 感謝 指教
07/24 23:58, 3F
文章代碼(AID): #1G3b2OOJ (AndroidDev)