2
다음 코드를 사용하여 지오 코더를 정의되지 않은 상태로 유지합니다. 나는 단순히 위도와 경도의 장소 주소를 얻으려고 노력하고있다. 지오 코더 지오 코더 선 = 새 지오 코더 (this, Locale.ENGLISH); 항상 undifined로 되돌아옵니다. 이 정의되지 않은 때문이다생성자 Geocoder()가 정의되지 않았습니다.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
/* Use the LocationManager class to obtain GPS locations */
LocationManager mlocManager =
(LocationManager)getSystemService(Context.LOCATION_SERVICE);
LocationListener mlocListener = new MyLocationListener();
mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 600000, 1000, mlocListener);
/* Class My Location Listener */
public class MyLocationListener implements LocationListener
{
@Override
public void onLocationChanged(Location loc)
{
loc.getLatitude();
loc.getLongitude();
Geocoder geocoder = new Geocoder(this, Locale.ENGLISH);
currentLatitude = loc.getLatitude();
currentLongitude = loc.getLongitude();
try {
List<Address> addresses = geocoder.getFromLocation(currentLatitude, currentLongitude, 1);
if(addresses != null) {
Address returnedAddress = addresses.get(0);
StringBuilder strReturnedAddress = new StringBuilder("Address:\n");
for(int i=0; i<returnedAddress.getMaxAddressLineIndex(); i++) {
strReturnedAddress.append(returnedAddress.getAddressLine(i)).append("\n");
}
myAddress.setText(strReturnedAddress.toString());
}
else{
myAddress.setText("No Address returned!");
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
myAddress.setText("Canont get Address!");
}
아직도 약간 혼란 스럽지만,은 내 구체적인 경우에 무엇이 될까요? –
63alfred
예, 훌륭했습니다. 이제 안드로이드에서 쉼표로 구분 된 파일을 읽는 방법을 모색 중입니다. 먼저 응용 프로그램에서 읽을 수 있도록 위치를 알아야합니다. 쉼표로 구분 된 파일의 데이터를 스팅 또는 자바 파일의 배열로 전송할 수 있지만 거기에 쉼표로 구분 된 파일을 놓고 읽는 방법이 있어야합니다. 게다가 쉼표로 구분 된 파일은 텍스트이기 때문에 많은 수의 비트가 아니라 3000 개의 항목과 비슷하지만 많은 입력이 필요합니다. – 63alfred