I got the Latitude and longitude values in Emulator using Telnet.(i.e) GPS.
I have a doubt (i.e) without google map can we able to get the current location using the latitude and longitude.
I got the Latitude and longitude values in Emulator using Telnet.(i.e) GPS.
I have a doubt (i.e) without google map can we able to get the current location using the latitude and longitude.
GPSとGoogleマップの両方を使用して現在地を取得できます。グーグルマップを介して場所を取得したい場合は、plzはこのチュートリアルを表示します。そして、あなたはこの以前に尋ねられた質問を見ることができます。
Googleマップなしで位置情報を取得したい場合は、位置情報マネージャーを使用できます。
これを行うには、OnCreateメソッドに休眠コードを追加する必要があります。
/* 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);
カスタムクラスでは、MyLocationListener usingは、インターフェイスLocationListenerを実装します。
独自のLocationリスナーを追加して、いくつかの関数をオーバーライドして、必要な処理を実行できるようにします。私たちの場合、休閑中の場合は画面にメッセージを出力します。
onLocationChanged ( Location Update )
onProviderDisabled ( GPS Off )
onProviderEnabled (GPS On )
そして、何もしない別の必須メソッドを追加します。
onStatusChanged (We are not adding nothing here).
その後、AndroidManifest.xmlファイルで権限を付与します。
android:name="android.permission.ACCESS_FINE_LOCATION"
このコードで緯度と経度を取得できます
GPS_Location mGPS = new GPS_Location(MyApplication.getAppContext());
if (mGPS.canGetLocation) {
mLat = mGPS.getLatitude();
mLong = mGPS.getLongitude();
} else {
System.out.println("cannot find");
}
gps 権限とその他の権限をアプリに追加する必要があります