diff --git a/.idea/misc.xml b/.idea/misc.xml
index 37013f1..a444d11 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,12 +3,11 @@
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 159f0bc..eae7097 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -3,6 +3,9 @@
xmlns:tools="http://schemas.android.com/tools"
package="com.example.nemophila">
+
+
+
+ android:label="@string/title_activity_gps">
@@ -26,17 +29,30 @@
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
+
+
-
-
+ android:label="@string/title_activity_post">
-
+ android:label="@string/title_activity_shop">
\ No newline at end of file
diff --git a/app/src/main/java/com/example/nemophila/GpsActivity.java b/app/src/main/java/com/example/nemophila/GpsActivity.java
new file mode 100644
index 0000000..9d13124
--- /dev/null
+++ b/app/src/main/java/com/example/nemophila/GpsActivity.java
@@ -0,0 +1,134 @@
+package com.example.nemophila;
+
+import androidx.activity.result.ActivityResultLauncher;
+import androidx.activity.result.contract.ActivityResultContracts;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.app.ActivityCompat;
+import androidx.core.content.ContextCompat;
+
+import android.annotation.SuppressLint;
+import android.net.Uri;
+import android.os.Bundle;
+import android.content.pm.PackageManager;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.widget.TextView;
+import android.content.Intent;
+import android.provider.Settings;
+import android.util.Log;
+import android.widget.Toast;
+import android.Manifest;
+
+import android.os.Bundle;
+
+public class GpsActivity extends AppCompatActivity implements LocationListener {
+
+ LocationManager locationManager;
+
+ private final ActivityResultLauncher
+ requestPermissionLauncher = registerForActivityResult(
+ new ActivityResultContracts.RequestPermission(),
+ isGranted -> {
+ if (isGranted) {
+ locationStart();
+ }
+ else {
+ Toast toast = Toast.makeText(this,
+ "これ以上なにもできません", Toast.LENGTH_SHORT);
+ toast.show();
+ }
+ });
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_gps);
+
+ if (ActivityCompat.checkSelfPermission(this,
+ Manifest.permission.ACCESS_FINE_LOCATION)
+ != PackageManager.PERMISSION_GRANTED) {
+
+ requestPermissionLauncher.launch(
+ Manifest.permission.ACCESS_FINE_LOCATION);
+ }
+ else{
+ locationStart();
+ }
+ }
+
+ private void locationStart(){
+ Log.d("debug","locationStart()");
+
+ // LocationManager インスタンス生成
+ locationManager =
+ (LocationManager) getSystemService(LOCATION_SERVICE);
+
+ if (locationManager != null && locationManager.isProviderEnabled(
+ LocationManager.GPS_PROVIDER)) {
+
+ Log.d("debug", "location manager Enabled");
+ } else {
+ // GPSを設定するように促す
+ Intent settingsIntent =
+ new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+ startActivity(settingsIntent);
+ Log.d("debug", "not gpsEnable, startActivity");
+ }
+
+ if (ContextCompat.checkSelfPermission(this,
+ Manifest.permission.ACCESS_FINE_LOCATION) !=
+ PackageManager.PERMISSION_GRANTED) {
+ ActivityCompat.requestPermissions(this,
+ new String[]{Manifest.permission.ACCESS_FINE_LOCATION,}, 1000);
+
+ Log.d("debug", "checkSelfPermission false");
+ return;
+ }
+
+ //解決しているはずの問題にエラーが起きています
+ //実行はできます
+ locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
+ 1000, 50, this);
+
+ }
+
+
+ @SuppressLint("QueryPermissionsNeeded")
+ private void moveToGMap(Location location){
+ String str1 = String.valueOf(location.getLatitude());
+ String str2 = String.valueOf(location.getLongitude());
+
+ Uri uri = Uri.parse("geo:"+str1+","+str2+"?z=16");
+
+ Intent intent = new Intent(Intent.ACTION_VIEW, uri);
+ startActivity(intent);
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+ }
+
+ @Override
+ public void onLocationChanged(Location location) {
+ // 緯度の表示
+ TextView textView1 = findViewById(R.id.text_view1);
+ String str1 = "Latitude:"+location.getLatitude();
+ textView1.setText(str1);
+
+ // 経度の表示
+ TextView textView2 = findViewById(R.id.text_view2);
+ String str2 = "Longitude:"+location.getLongitude();
+ textView2.setText(str2);
+ }
+
+ @Override
+ public void onProviderEnabled(String provider) {
+
+ }
+
+ @Override
+ public void onProviderDisabled(String provider) {
+
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/nemophila/MainActivity.java b/app/src/main/java/com/example/nemophila/MainActivity.java
index 3ddbb30..faa4487 100644
--- a/app/src/main/java/com/example/nemophila/MainActivity.java
+++ b/app/src/main/java/com/example/nemophila/MainActivity.java
@@ -71,8 +71,8 @@
mMap = googleMap;
//研究室周辺の緯度経度
- double latitude = 34.735;
- double longitude = 135.26;
+ double latitude = 34.7308032;
+ double longitude = 135.2630272;
latlng = new LatLng(latitude, longitude);
//テスト用
diff --git a/app/src/main/res/layout/activity_gps.xml b/app/src/main/res/layout/activity_gps.xml
new file mode 100644
index 0000000..8571a51
--- /dev/null
+++ b/app/src/main/res/layout/activity_gps.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index e19fa4c..868e21d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -6,5 +6,6 @@
ShopActivity
LoginActivity
SignUpActivity
+ GpsActivity
\ No newline at end of file