###前提・実現したいこと
現在gpsを利用した鬼ごっこアプリを開発しています。下記のコードはメインのコードです。
「onLocationChanged」ってメソッドが、位置情報が更新されたときに呼び出されるものになります。
それが実行されると、現在地の緯度と経度を「latlng」っていう変数に格納して、その位置にマーカー(アイコン画像)を表示して、マップの真ん中に来るようにカメラを移動させるという動きをします。
###発生している問題・エラーメッセージ
latlngに格納した自分の位置情報を自分のパソコン上の仮想サーバに送るというプログラムをどうやってかけばよいか
わかりません。
###該当のソースコード
package ***;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationManager;
import android.location.LocationProvider;
import android.os.CountDownTimer;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import android.location.LocationListener;
import android.widget.Toast;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback, LocationListener {
private GoogleMap mMap; private Marker marker = null; private LocationManager locationManager; private TextView timerText; private int times; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_maps); // Obtain the SupportMapFragment and get notified when the map is ready to be used. SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); mapFragment.getMapAsync(this); locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION,}, 1000); } else{ locationStart(); } SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); String time = sharedPreferences.getString("time", "3"); if (time.equals("3")){ times = 180000; }else{ times = 300000; } } public void onMapReady(GoogleMap googleMap) {
###補足情報(言語/FW/ツール等のバージョンなど)
・java
・Android Studio
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。