protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Main); textView = FindViewById <TextView>(Resource.Id.HELLO); networkTextView = FindViewById <TextView>(Resource.Id.network); // Requests app ActivityCompat.RequestPermissions(this, MotionDnaApplication.NeedsRequestingPermissions(), REQUEST_MDNA_PERMISSIONS); }
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Permission[] grantResults) { if (MotionDnaApplication.CheckMotionDnaPermissions(this)) // permissions already requested { // Starts a foreground service to ensure that the // App continues to sample the sensors in background motionDnaServiceIntent = new Intent(this, typeof(MotionDnaForegroundService)); StartService(motionDnaServiceIntent); // Start the MotionDna Core StartMotionDna(); } }
public void StartMotionDna() { if (devKey.Equals("<ENTER YOUR DEV KEY HERE>")) { var alert = new AlertDialog.Builder(this); alert.SetMessage("Enter your Navisens Dev Key.").SetCancelable(false).SetNeutralButton("Ok", delegate { alert.Dispose(); return; }).Show(); } motionDnaApplication = new MotionDnaApplication(this); // This functions starts up the SDK. You must pass in a valid developer's key in order for // the SDK to function. IF the key has expired or there are other errors, you may receive // those errors through the reportError() callback route. motionDnaApplication.RunMotionDna(devKey); // Use our internal algorithm to automatically compute your location and heading by fusing // inertial estimation with global location information. This is designed for outdoor use and // will not compute a position when indoors. Solving location requires the user to be walking // outdoors. Depending on the quality of the global location, this may only require as little // as 10 meters of walking outdoors. motionDnaApplication.SetLocationNavisens(); // Set accuracy for GPS positioning, states :HIGH/LOW_ACCURACY/OFF, OFF consumes // the least battery. motionDnaApplication.SetExternalPositioningState(MotionDna.ExternalPositioningState.LowAccuracy); // Manually sets the global latitude, longitude, and heading. This enables receiving a // latitude and longitude instead of cartesian coordinates. Use this if you have other // sources of information (for example, user-defined address), and need readings more // accurate than GPS can provide. // motionDnaApplication.setLocationLatitudeLongitudeAndHeadingInDegrees(37.787582, -122.396627, 0); // Set the power consumption mode to trade off accuracy of predictions for power saving. motionDnaApplication.SetPowerMode(MotionDna.PowerConsumptionMode.Performance); // Connect to your own server and specify a room. Any other device connected to the same room // and also under the same developer will receive any udp packets this device sends. motionDnaApplication.StartUDP(); // Allow our SDK to record data and use it to enhance our estimation system. // Send this file to [email protected] if you have any issues with the estimation // that you would like to have us analyze. motionDnaApplication.SetBinaryFileLoggingEnabled(true); // Tell our SDK how often to provide estimation results. Note that there is a limit on how // fast our SDK can provide results, but usually setting a slower update rate improves results. // Setting the rate to 0ms will output estimation results at our maximum rate. motionDnaApplication.SetCallbackUpdateRateInMs(500); // When setLocationNavisens is enabled and setBackpropagationEnabled is called, once Navisens // has initialized you will not only get the current position, but also a set of latitude // longitude coordinates which lead back to the start position (where the SDK/App was started). // This is useful to determine which building and even where inside a building the // person started, or where the person exited a vehicle (e.g. the vehicle parking spot or the // location of a drop-off). motionDnaApplication.SetBackpropagationEnabled(true); // If the user wants to see everything that happened before Navisens found an initial // position, he can adjust the amount of the trajectory to see before the initial // position was set automatically. motionDnaApplication.SetBackpropagationBufferSize(2000); // Enables AR mode. AR mode publishes orientation quaternion at a higher rate. // motionDnaApplication.setARModeEnabled(true); }