버튼을 클릭 할 때 사용자의 위치를 얻으려고합니다.
위치 관리자 android problem
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
Criteria criteria = new Criteria();
bestProvider = locationManager.getBestProvider(criteria, false);
Location currentLocation = locationManager.getLastKnownLocation(bestProvider);
Log.e(tag,"reached till here");
location = Double.toString(currentLocation.getLatitude()) + " " + Double.toString(currentLocation.getLongitude());
Toast.makeText(getApplicationContext(), location, Toast.LENGTH_LONG);
MyLocation.setText(location);
내가 로그 캣에 출력 reached till here
을 얻고있다 :
나는 나의 버튼에 다음 코드는 리스너를 onclick을했다. 그 후 응용 프로그램이 중지되고 강제로 닫으라는 메시지가 표시됩니다. 처음에 몇 가지 검색을 수행하여 getLatitude 및 getLongitude가 double 값을 반환한다는 것을 알았습니다. 그래서 코드를 수정했습니다. 하지만 여전히 오류가 발생합니다. 내가 도대체 뭘 잘못하고있는 겁니까?
편집 : 로그 캣 오류 : 796 UID 10036
을 PID하는
있어 RemoteException을 보내는 setActive (false)를 통지 내가 currentLocation가 반환 생각 널
디버깅 및 개체 "currentLocation는"null의 경우 볼 수 있습니까? 또한 logcat에서 얻은 오류는 무엇입니까? – Finuka
logcat을 게시하여 충돌하는 이유를 찾습니다. – PravinCG
로그를 보여주십시오. 마지막으로 알려진 위치가 없을 수도 있습니다. 그렇다면 null이 생깁니다. – TofferJ