다음 코드를 붙여 넣기 복사 : link. 에뮬레이터 대신 활성 장치를 사용할 때 위치 정보가 표시되지 않았습니다. 심지어 GPS가 활성화되었습니다GPS에서 위치 정보 수정 없음 - Android
public class UseGps extends Activity
{
/** Called when the activity is first created. */
@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, 0, 0, mlocListener);
}
/* Class My Location Listener */
public class MyLocationListener implements LocationListener
{
@Override
public void onLocationChanged (Location loc)
{
loc.getLatitude();
loc.getLongitude();
String Text = "My current location is: " + "Latitud = " + loc.getLatitude() + "Longitud = " + loc.getLongitude();
Toast.makeText (getApplicationContext(), Text, Toast.LENGTH_SHORT).show();
}
@Override
public void onProviderDisabled (String provider)
{
Toast.makeText (getApplicationContext(), "Gps Disabled", Toast.LENGTH_SHORT).show();
}
@Override
public void onProviderEnabled (String provider)
{
Toast.makeText (getApplicationContext(), "Gps Enabled", Toast.LENGTH_SHORT).show();
}
@Override
public void onStatusChanged (String provider, int status, Bundle extras)
{
}
}/* End of Class MyLocationListener */
}/* End of UseGps Activity */
권한을 추가 했습니까? –
예. 여전히 변화가 없다. – User16
에 매니페스트를 표시하십시오. –