示例#1
0
            protected override Java.Lang.Void RunInBackground(params WeakReference<Activity>[] @params)
            {
                
                Activity param1;
                @params[0].TryGetTarget(out param1); //to replace params[0].get() as it was in Java
                ConsentListener param2 = new ConsentListener(o_);

                try
                {
                    if (o_.getConnectedBandClient()) {
                        if (param1 != null) {
                            o_.client.SensorManager.RequestHeartRateConsent(param1, param2); 
                        }
                    } else {
                        o_.appendToUI("Band isn't connected. Please make sure bluetooth is on and the band is in range.\n");
                        o_.setVisibility(true);
                    }
                } catch (BandException e) {
                    string exceptionMessage = "Band Exception: Either Microsoft Health BandService is not available or \n" +
                        "Microsoft Health BandService doesn't support your SDK Version. Please update to latest SDK\n"
                        + e.Message.ToString();
                    o_.appendToUI(exceptionMessage);
                
                    }
                    catch (System.Exception e) {
                        o_.appendToUI(e.Message.ToString());
                    }
                    return null;
            } //end of RunInBackground
示例#2
0
 protected override Java.Lang.Void RunInBackground(params Java.Lang.Void[] @params)
 {
     try
     {
         if (o_.getConnectedBandClient())
         {
             if (o_.client.SensorManager.CurrentHeartRateConsent == UserConsent.Granted)
             {
                 o_.client.SensorManager.RegisterHeartRateEventListener(o_.mHeartRateEventListener);
                 o_.setVisibility(false); 
             }
         }
     } catch (System.Exception e) {
         o_.appendToUI(e.Message.ToString());
     }
         return null;
 }