protected override void OnResume()
        {
            base.OnResume();

            // ArFragment of Sceneform automatically requests the camera permission before creating the AR session,
            // so we don't need to request the camera permission explicitly.
            // This will cause onResume to be called again after the user responds to the permission request.
            if (!SceneformHelper.HasCameraPermission(this))
            {
                return;
            }

            if (sceneView?.Session is null && !SceneformHelper.TrySetupSessionForSceneView(this, sceneView))
            {
                // Exception will be logged and SceneForm will handle any ARCore specific issues.
                Finish();
                return;
            }

            if (string.IsNullOrWhiteSpace(AccountDetails.SpatialAnchorsAccountId) || AccountDetails.SpatialAnchorsAccountId == "Set me" ||
                string.IsNullOrWhiteSpace(AccountDetails.SpatialAnchorsAccountKey) || AccountDetails.SpatialAnchorsAccountKey == "Set me" ||
                string.IsNullOrWhiteSpace(AccountDetails.SpatialAnchorsAccountDomain) || AccountDetails.SpatialAnchorsAccountDomain == "Set me")
            {
                Toast.MakeText(this, $"\"Set {AccountDetails.SpatialAnchorsAccountId}, {AccountDetails.SpatialAnchorsAccountKey}, and {AccountDetails.SpatialAnchorsAccountDomain} in {nameof(AccountDetails)}.cs\"", ToastLength.Long)
                .Show();

                Finish();
                return;
            }

            SensorPermissionsHelper.RequestMissingPermissions(this);

            cloudAnchorManager = new AzureSpatialAnchorsManager(sceneView.Session);
            cloudAnchorManager.StartSession();

            locationProvider = new PlatformLocationProvider();
            locationProvider.Sensors.SetKnownBeaconProximityUuids(CoarseRelocSettings.KnownBluetoothProximityUuids);
            SensorPermissionsHelper.EnableAllowedSensors(this, locationProvider);
            cloudAnchorManager.LocationProvider = locationProvider;

            sensorStatusView.Model = new LocationProviderSensorStatus(locationProvider);
        }
Esempio n. 2
0
 public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
 {
     SensorPermissionsHelper.PermissionsResult outcome =
         SensorPermissionsHelper.OnRequestPermissionsResult(this, requestCode);
     if (outcome == SensorPermissionsHelper.PermissionsResult.Allowed)
     {
         if (locationProvider != null)
         {
             SensorPermissionsHelper.EnableAllowedSensors(this, locationProvider);
         }
     }
     else if (outcome == SensorPermissionsHelper.PermissionsResult.Denied)
     {
         Toast.MakeText(
             this,
             "Location permission is needed to run this demo",
             ToastLength.Long)
         .Show();
         Finish();
     }
 }