Parcourir la source

運行開始・終了で落ちる部分を修正

y.tomita il y a 5 mois
Parent
commit
f986a3383c

+ 3 - 1
app/src/main/AndroidManifest.xml

@@ -22,7 +22,9 @@
         android:supportsRtl="true"
         android:theme="@style/AppTheme"
         android:usesCleartextTraffic="true"
-        tools:ignore="AllowBackup">
+        tools:ignore="AllowBackup"
+        android:enableOnBackInvokedCallback="true"
+        >
 
         <service
             android:name=".service.DriveService"

+ 10 - 3
app/src/main/java/jp/co/ecosysnetwork/ccloca_app/activity/MainActivity.java

@@ -11,6 +11,7 @@ import android.os.Bundle;
 import android.os.Handler;
 import android.os.Looper;
 import android.os.PowerManager;
+import android.util.Log;
 import android.util.Xml;
 import android.view.View;
 import android.widget.Button;
@@ -294,6 +295,7 @@ public class MainActivity
                 getString(R.string.yes),
                 getString(R.string.no)
         );
+
         newFragment.show(getSupportFragmentManager(), DIALOG_TAG_EXIT);
     }
     /**
@@ -672,8 +674,10 @@ public class MainActivity
                         double lat = loc.getLatitude();     // 緯度
                         double lon = loc.getLongitude();    // 経度
                         float acc = loc.getAccuracy();      // 精度
+
                         // 取得値が最低精度を満たしている場合、位置情報制御を実施する
-                        if ((acc < MIN_ACC) && (0 < lat) && (0 < lon)) {
+//                        if ((acc < MIN_ACC) && (0 < lat) && (0 < lon)) {
+                        if ((acc < MIN_ACC) && (0 < lat) && (-180 < lon)) {
                             callStartExec(lat, lon);
                         }
                     }
@@ -699,7 +703,8 @@ public class MainActivity
                         double lon = loc.getLongitude();    // 経度
                         float acc = loc.getAccuracy();      // 精度
                         // 取得値が最低精度を満たしている場合、位置情報制御を実施する
-                        if ((acc < MIN_ACC) && (0 < lat) && (0 < lon)) {
+//                        if ((acc < MIN_ACC) && (0 < lat) && (0 < lon)) {
+                        if ((acc < MIN_ACC) && (0 < lat) && (-180 < lon)) {
                             callEndExec(lat, lon);
                         }
                     }
@@ -734,7 +739,9 @@ public class MainActivity
         super.onDestroy();
         // 表示更新の解除
         if (_refreshDisplayRunnable != null) {
-            _refreshDisplayHandler.removeCallbacks(_refreshDisplayRunnable);
+            if (_refreshDisplayHandler != null)  {
+                _refreshDisplayHandler.removeCallbacks(_refreshDisplayRunnable);
+            }
         }
         // サービスの停止
         Intent intent = new Intent(this, DriveService.class);