소스자체에는 문제가 없다고 생각합니다..
모토로이 자체에서 돌려봤으나 돌아오는 값이 없는데 이 문제 진단 부탁드립니다.
문제는 가져오는 값이 NULL값이라 에러처리문의 문장이 나오더군요..
구동은 모토로이로 직접.. 구동했습니다..
02-16 21:43:32.936: ERROR/StatusBarPolicy(1317): Modified icon Level=5
02-16 21:47:18.694: ERROR/NetworkStateTracker(1317): net.tcp.buffersize.hsdpa not found in system properties. Using defaults
02-16 22:02:59.678: ERROR/AndroidRuntime(20502): ERROR: thread attach failed
02-16 22:03:01.014: ERROR/AndroidRuntime(20519): ERROR: thread attach failed
02-16 22:03:09.155: ERROR/StatusBarPolicy(1317): Modified icon Level=5
02-16 22:03:11.186: ERROR/StatusBarPolicy(1317): Modified icon Level=4
02-16 22:03:41.717: ERROR/AndroidRuntime(20542): ERROR: thread attach failed
02-16 22:03:42.999: ERROR/AndroidRuntime(20553): ERROR: thread attach failed
02-16 22:03:52.858: ERROR/SUPLJ(1317): Select() returned!!
02-16 22:03:53.053: ERROR/SUPLJ(1317): Select() returned!!
02-16 22:03:53.319: ERROR/SUPLJ(1317): Select() returned!!
02-16 22:03:53.921: ERROR/StatusBarPolicy(1317): Modified icon Level=4
[mainfest에는 퍼미션 줬구요..]
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"></uses-permission>
[GPS.java]
package com.ex.Gps; import android.app.Activity; import android.content.Context; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.util.Log; import android.widget.TextView;
public class Gps extends Activity { private LocationManager lm; private LocationListener locListenD; public TextView tvLatitude; public TextView tvLongitude;
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // 텍스트뷰를 찾는다 tvLatitude = (TextView)findViewById(R.id.tvLatitude); tvLongitude = (TextView)findViewById(R.id.tvLongitude); // LocationListener의 핸들을 얻는다 lm =(LocationManager)getSystemService(Context.LOCATION_SERVICE); //GPS 위치 서비스에 연결한다 Location loc = lm.getLastKnownLocation("gps"); if(loc!=null) { // TextView를 채운다 tvLatitude.setText(Double.toString(loc.getLatitude())); tvLongitude.setText(Double.toString(loc.getLongitude()));
// Location Manager에게 위치정보를 업데이트해달라고 요청한다. locListenD = new DispLocListener(); lm.requestLocationUpdates("gps", 30000L, 10.0f, locListenD); } else { Log.d("location", "location is null"); } }
private class DispLocListener implements LocationListener { public void onLocationChanged(Location location) { // TextView를 업데이트 한다. tvLatitude.setText(Double.toString(location.getLatitude())); tvLongitude.setText(Double.toString(location.getLongitude())); } public void onProviderDisabled(String provider) { } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider, int status, Bundle extras) { } } }
[main.xml]
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@+id/lblLatitude" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Latitude:" /> <TextView android:id="@+id/tvLatitude" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <TextView android:id="@+id/lblLongitude" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Longitude:" /> <TextView android:id="@+id/tvLongitude" android:layout_width="fill_parent" android:layout_height="wrap_content"/> </LinearLayout>
저도 같은 문제에 봉착해있는중입니다 ( 아래 제가 올린 글과 어느 분의 조언 )
http://www.androidpub.com/?mid=android_dev_qna&page=2&document_srl=130868
문제 해결되면 서로 공유하기로 해요 ^^
시간이많이지났지만 질문하나할게요 ㅠㅠ
'도루'님께서 말씀하신 해결방안인