Bläddra i källkod

Starting....2

Thomas Chef 3 år sedan
förälder
incheckning
23536698cd

+ 17 - 0
.idea/deploymentTargetDropDown.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="deploymentTargetDropDown">
+    <runningDeviceTargetSelectedWithDropDown>
+      <Target>
+        <type value="RUNNING_DEVICE_TARGET" />
+        <deviceKey>
+          <Key>
+            <type value="SERIAL_NUMBER" />
+            <value value="adb-y55x59fuozusvcbu-8Fp8GF._adb-tls-connect._tcp." />
+          </Key>
+        </deviceKey>
+      </Target>
+    </runningDeviceTargetSelectedWithDropDown>
+    <timeTargetWasSelectedWithDropDown value="2022-06-23T16:37:36.525665Z" />
+  </component>
+</project>

+ 11 - 3
app/src/main/java/com/flacksta/chef/journeygpstracker/MainActivity.java

@@ -14,22 +14,29 @@ import android.util.Log;
 public class MainActivity extends AppCompatActivity {
 
     final String TAG = "MainActivity";
+    Context appContx = null;
+    boolean locPermGranted = false;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);
 
-        Context appContx = getApplicationContext();
+        appContx = getApplicationContext();
 
         final int hasPermission = ContextCompat.checkSelfPermission(appContx, Manifest.permission.ACCESS_FINE_LOCATION);
-        Log.i(TAG, "Permission: " + Integer.toString(hasPermission) );
+
         if( hasPermission == PackageManager.PERMISSION_DENIED ) {
             Log.i(TAG, "Requesting permissions.....");
             locationPermissionRequest.launch(new String[]{
-                    Manifest.permission.ACCESS_FINE_LOCATION
+                    Manifest.permission.ACCESS_FINE_LOCATION,
+                    Manifest.permission.ACCESS_COARSE_LOCATION
             });
         }
+        else {
+            Log.i(TAG, "Permissions already granted.");
+            locPermGranted = true;
+        }
     }
 
     ActivityResultLauncher<String[]> locationPermissionRequest =
@@ -42,6 +49,7 @@ public class MainActivity extends AppCompatActivity {
                         if (fineLocationGranted != null && fineLocationGranted) {
                             // Precise location access granted.
                             Log.i(TAG,"Precise location granted");
+                            locPermGranted = true;
                         } else if (coarseLocationGranted != null && coarseLocationGranted) {
                             // Only approximate location access granted.
                             Log.i(TAG,"approximate location granted");