안드로이드 개발 질문/답변
(글 수 45,052)
아주 간단한 소슨데 실행이 안되네요 . 위치를 못찾아옴
애물도 안되고 갤스에서도 안되네요 문제가 먼지 모르겟음
LocationManager locationManager = null; String context = Context.LOCATION_SERVICE; locationManager = (LocationManager)getSystemService(context); String provider = LocationManager.GPS_PROVIDER; Location location = locationManager.getLastKnownLocation(provider); TextView textView = (TextView)findViewById(R.id.text); if(location!=null){ Double lat = location.getLatitude(); Double lng = location.getLongitude(); textView.setText("위도:" + lat +"\n경도:"+ lng); }else{ textView.setText("위치를 찾을 수 없습니다."); }
manifest에 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 추가했어요