protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.attend_layout); token = Intent.Extras.GetString("token"); _nfcAdapter = NfcAdapter.GetDefaultAdapter(this); if (_nfcAdapter == null) { Intent intent = new Intent(this, typeof(NoNFCActivity)); StartActivity(intent); } else { NfcAdapter adapter = NfcAdapter.GetDefaultAdapter(this); adapter.SetNdefPushMessageCallback(this, this); adapter.SetOnNdefPushCompleteCallback(this, this); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); // Get a reference to the default NFC adapter for this device. This adapter // is how an Android application will interact with the actual hardware. _nfcAdapter = NfcAdapter.GetDefaultAdapter(this); _writeTagButton = FindViewById <Button>(Resource.Id.write_tag_button); _writeTagButton.Click += WriteTagButtonOnClick; _readTagButton = FindViewById <Button>(Resource.Id.read_tag_button); _readTagButton.Click += ReadTagButtonOnClick; _textView = FindViewById <TextView>(Resource.Id.text_view); _inputText = FindViewById <EditText>(Resource.Id.input_text); _inputText.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => { nfcdata = e.Text.ToString(); }; String ssid = getWifiInfo(); DisplayMessage(ssid); }
/* * learning from * http://blog.csdn.net/earbao/article/details/50961713 */ protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById <Button>(Resource.Id.ScanButton); button.Click += Scan;; var writerButton = FindViewById <Button>(Resource.Id.WriteButton); writerButton.Click += Write; var label = FindViewById <TextView>(Resource.Id.ResultLabel); nfcAdapter = NfcAdapter.GetDefaultAdapter(ApplicationContext); if (nfcAdapter == null) { label.Text = "NFC is not available."; return; } if (!nfcAdapter.IsEnabled) { label.Text = "NFC is disabled."; return; } //nfcAdapter.SetNdefPushMessageCallback(this, this); var intent = new Intent(this, this.Class); intent.AddFlags(ActivityFlags.SingleTop); nfcPi = PendingIntent.GetActivity(this, 0, intent, 0); nfcFilter = new IntentFilter(NfcAdapter.ActionNdefDiscovered); nfcFilter.AddCategory(Intent.CategoryDefault); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); this.SetContentView(Resource.Layout.Main); mInfoText = FindViewById <TextView> (Resource.Id.textView); // Check for available NFC Adapter mNfcAdapter = NfcAdapter.GetDefaultAdapter(this); if (mNfcAdapter == null) { mInfoText = FindViewById <TextView> (Resource.Id.textView); mInfoText.Text = "NFC is not available on this device."; } else { // Register callback to set NDEF message mNfcAdapter.SetNdefPushMessageCallback(this, this); // Register callback to listen for message-sent success mNfcAdapter.SetOnNdefPushCompleteCallback(this, this); } }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); _nfc_avaible = false; _do_scanning = false; _nfc_adapter = NfcAdapter.GetDefaultAdapter(this); if (_nfc_adapter != null) { _nfc_avaible = true; _pending_intent = PendingIntent.GetActivity(this, 0, new Intent(this, GetType()).AddFlags(ActivityFlags.SingleTop), 0); _filters = new IntentFilter[] { new IntentFilter(NfcAdapter.ActionTagDiscovered) }; } Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); LoadApplication(new App()); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.Inflate(Resource.Layout.fragment_scan_tag, container, false); Button clearButton = view.FindViewById <Button>(Resource.Id.clearButton); clearButton.Click += ClearButton_Click; var nfcAdapter = NfcAdapter.GetDefaultAdapter(MainActivity.Instance); var mainTextView = view.FindViewById <TextView>(Resource.Id.mainTextView); if (nfcAdapter == null) { mainTextView.Text = "No NFC Adapter found!"; } else if (!nfcAdapter.IsEnabled) { mainTextView.Text = "NFC Adapter is disabled!"; } return(view); }
public IObservable <NDefRecord[]> Reader() => Observable.Create <NDefRecord[]>(ob => { var adapter = NfcAdapter.GetDefaultAdapter(this.context.AppContext); adapter.EnableReaderMode( this.context.CurrentActivity, this, NfcReaderFlags.NfcA | NfcReaderFlags.NfcB | NfcReaderFlags.NfcBarcode | NfcReaderFlags.NfcF | NfcReaderFlags.NfcV | NfcReaderFlags.NoPlatformSounds, new Android.OS.Bundle() ); var sub = this.recordSubj.Subscribe(ob.OnNext); return(() => { adapter.DisableReaderMode(this.context.CurrentActivity); sub.Dispose(); }); });
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); StatusBarTintHelper.SetStatusBarColor(this); //// Create your application here SetContentView(Resource.Layout.settings_board_activity); llRootView = FindViewById <LinearLayout>(Resource.Id.llRootView); FindViewById <LinearLayout>(Resource.Id.llStatusBarStub).LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, StatusBarTintHelper.GetStatusBarHeight()); toolbar = FindViewById <Toolbar>(Resource.Id.toolbar_actionbar); SetSupportActionBar(toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetDisplayShowHomeEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); wvContent = FindViewById <WebView>(Resource.Id.wvContent); wvContent.Settings.JavaScriptEnabled = true; wvContent.AddJavascriptInterface(this, "wst"); var HtmlTemplate = ""; using (var sr = new StreamReader(MainApp.ThisApp.Assets.Open("wst.html"))) { HtmlTemplate = sr.ReadToEnd(); } wvContent.LoadDataWithBaseURL( "file:///android_asset/html/", HtmlTemplate, "text/html", "utf-8", null); _nfcAdapter = NfcAdapter.GetDefaultAdapter(this); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); txtStatus = (TextView)FindViewById(Resource.Id.txtStatus); btnGetSAMInfo = (Button)FindViewById(Resource.Id.btnGetSAMInfo); btnGetSAMInfo.Click += onClickGetSAMInfo; getVersionAPDUs.Add(SAMType.Mifare, new byte[] { (byte)0x80, (byte)0x60, (byte)0x00, (byte)0x00, /*(byte)0x00,*/ (byte)0x00 }); getVersionAPDUs.Add(SAMType.Felica, new byte[] { (byte)0xA0, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x05, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xE6, (byte)0x00, (byte)0x00 }); nfcAdapter = NfcAdapter.GetDefaultAdapter(this); if (nfcAdapter == null) { Toast.MakeText(this, GetString(Resource.String.message_nfc_not_supported), ToastLength.Long).Show(); Finish(); return; } nfcIntent = PendingIntent.GetActivity(this, 0, new Intent(this, this.Class) .AddFlags(ActivityFlags.SingleTop), 0); //The EMDKManager object will be created and returned in the callback. EMDKResults results = EMDKManager.GetEMDKManager(Application.Context, this); //Check the return status of EMDKManager object creation. if (results.StatusCode == EMDKResults.STATUS_CODE.Success) { //EMDKManager object creation success } else { //EMDKManager object creation failed } }
protected override void OnCreate(Bundle savedInstanceState) { Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("MjMyNTM4QDMxMzgyZTMxMmUzMGk5SnZMR3JhaWRBSzY0cEFCaDhQVGI0WDQ2ZDcrbTVYQVJWMmRyR0dybjA9"); TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); global::Xamarin.Forms.Forms.SetFlags("CollectionView_Experimental"); Xamarin.Essentials.Platform.Init(this, savedInstanceState); // CrossNFC.Init(this); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); Xamarin.FormsMaps.Init(this, savedInstanceState); CachedImageRenderer.Init(true); global::Xamarin.Auth.Presenters.XamarinAndroid.AuthenticationConfiguration.Init(this, savedInstanceState); LoadApplication(new App()); _nfcAdapter = NfcAdapter.GetDefaultAdapter(this); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.KeyGen); text = FindViewById <TextView>(Resource.Id.textView1); progBar = FindViewById <ProgressBar>(Resource.Id.progBar); finishedGen = FindViewById <Button>(Resource.Id.button1); startGen = FindViewById <Button>(Resource.Id.button2); pm = new PadManager(GetExternalFilesDir(null).ToString()); keys = new System.Collections.Generic.List <string>(); SetProgressBarIndeterminate(false); progBar.Progress = 0; progBar.Max = 100; finishedGen.Enabled = false; startGen.Click += StartGen_Click; finishedGen.Click += StartNfc_Click; _nfcAdapter = NfcAdapter.GetDefaultAdapter(this); if (_nfcAdapter == null) { text.Text = "NFC not available"; } if (pm == null) { text.Text = "Pad manager is null"; } // Get the contact name passed in through the intent when ViewContactActivity launches this intent contactName = Intent.GetStringExtra("contactName"); // stored in key "contactName" Identity.LoadUsername(GetExternalFilesDir(null).ToString()); myName = Identity.Username; text.Text = contactName; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.menuNFC); // Create your application here editMensagemPadrao = FindViewById <EditText>(Resource.Id.editMensagemPadrao); btn_formatarCartao = FindViewById <Button>(Resource.Id.btn_formatarCartao); btn_gravar = FindViewById <Button>(Resource.Id.btn_gravar); btn_ler = FindViewById <Button>(Resource.Id.btn_leitura); btn_teste = FindViewById <Button>(Resource.Id.btn_teste); mNfcAdapter = NfcAdapter.GetDefaultAdapter(this); painel_nfc = FindViewById <LinearLayout>(Resource.Id.painel_nfc); painel_nfc.Visibility = ViewStates.Invisible; painel_nfc_resposta = FindViewById <TextView>(Resource.Id.response); initViews(); InitNFC(); }
protected override void OnCreate(Bundle savedInstanceState) { CrossNFC.Init(this); base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.login); ComponentLocalizer(); ActionHooker(); NfcAdapter nfcAdapter = NfcAdapter.GetDefaultAdapter(this); if (nfcAdapter == null) { Android.Support.V7.App.AlertDialog.Builder alertDialog = new Android.Support.V7.App.AlertDialog.Builder(this); alertDialog.SetTitle(GetString(Resource.String.noNFC)); alertDialog.SetIcon(Resource.Drawable.ic1c_192x192); alertDialog.SetMessage(GetString(Resource.String.noSupport)); alertDialog.SetCancelable(false); alertDialog.SetNeutralButton(GetString(Resource.String.exit), delegate { Finish(); }); alertDialog.Show(); } CreateNotificationChannel(); }
public NfcService() { var activity = ((Activity)Xamarin.Forms.Forms.Context); nfcDevice = NfcAdapter.GetDefaultAdapter(activity); }
/// <summary> /// Default constructor /// </summary> public NFCImplementation() { _nfcAdapter = NfcAdapter.GetDefaultAdapter(CurrentContext); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Welcome); MediaPlayer media = MediaPlayer.Create(this, Resource.Raw.pleaseswipecard); media.Start(); Button LoginBtn = FindViewById <Button>(Resource.Id.LoginButton); EditText pinCode = FindViewById <EditText>(Resource.Id.CashierPINetxt); EditText IdField = FindViewById <EditText>(Resource.Id.CashierIDetxt); ImageView SettingsBtn = FindViewById <ImageView>(Resource.Id.settingsButton); var MSISDN = Application.Context.GetSharedPreferences("msisdn", Android.Content.FileCreationMode.Private); msisdn = MSISDN.GetString("MSISDN", null); if (!string.IsNullOrEmpty(msisdn)) { PublicVariables.MSISDN = msisdn; } var Municipality = Application.Context.GetSharedPreferences("municipality", Android.Content.FileCreationMode.Private); municipality = Municipality.GetString("Municipality", null); if (!string.IsNullOrEmpty(municipality)) { PublicVariables.MunicipalityName = municipality; } SettingsBtn.Click += delegate { Settings settings = new Settings(this); settings.Show(); }; IdField.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => { PublicVariables.CashierID = e.Text.ToString(); }; pinCode.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => { PublicVariables.CashierPIN = e.Text.ToString(); }; LoginBtn.Click += async delegate { if (string.IsNullOrEmpty(PublicVariables.CashierID) || string.IsNullOrEmpty(PublicVariables.CashierPIN)) { Toast.MakeText(this, "Please enter valid Cashier ID & PIN", ToastLength.Long).Show(); } else if (string.IsNullOrEmpty(PublicVariables.MunicipalityName) || string.IsNullOrEmpty(PublicVariables.MSISDN)) { Toast.MakeText(this, "Please enter valid settings", ToastLength.Long).Show(); Settings settings = new Settings(this); settings.Show(); } else { ProgressDialog p = new ProgressDialog(this); p.SetMessage("Logging in..."); p.Show(); WebService w = new WebService(); await w.GetCashier(); var loginResult = WebService.Message; if (loginResult == "Success") { Intent Activityintent = new Intent(this, typeof(MainActivity)); StartActivity(Activityintent); } else { Toast.MakeText(this, loginResult, ToastLength.Long).Show(); } p.Dismiss(); } }; mNfcAdapter = NfcAdapter.GetDefaultAdapter(this); if (mNfcAdapter == null) { return; } pendingIntent = PendingIntent.GetActivity(this, 0, new Intent(this, GetType()).AddFlags(ActivityFlags.SingleTop), 0); }
/// <summary> /// Default constructor /// </summary> public NFCImplementation() { _nfcAdapter = NfcAdapter.GetDefaultAdapter(CurrentContext); IsEnabled = IsAvailable && _nfcAdapter.IsEnabled; }
private void InitNFC() { base.OnStart(); mNfcAdapter = NfcAdapter.GetDefaultAdapter(this); }
public bool GetState() { NfcAdapter nfcAdapter = NfcAdapter.GetDefaultAdapter(Android.App.Application.Context); return(nfcAdapter.IsEnabled); }
protected override void OnCreate(Bundle bundle) { try { base.OnCreate(bundle); //展示页面 SetContentView(Resource.Layout.Main); CommonFunction.mode = "NFC"; //数据填充 Spinner TargetSpinner = FindViewById <Spinner>(Resource.Id.mSystemType); ArrayAdapter adapter = ArrayAdapter.CreateFromResource(this, Resource.Array.SystemType, Android.Resource.Layout.SimpleSpinnerItem); adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); TargetSpinner.Adapter = adapter; TargetSpinner.Prompt = "请选择"; TargetSpinner.ItemSelected += TargetSpinner_ItemSelected; //数据库操作 string documents = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); db = Path.Combine(documents, DataBaseName); bool exists = File.Exists(db); //判断文件中是否存在 数据表db 如果存在 获取数据,如果不存在 重置系统创建数据表 if (!exists) { InitSqlDB(db); } else { #region 获取数据 IsExistsSqlDB = true; var conn = new SqliteConnection("Data Source=" + db); var cmd = new SqliteCommand("select * from LoginTB limit 1", conn); cmd.CommandType = System.Data.CommandType.Text; try { conn.Open(); if (conn.State == System.Data.ConnectionState.Open) { SqliteDataReader sdr = cmd.ExecuteReader(); if (sdr.Read()) { int id = 0; Spinner SystemSpinner = FindViewById <Spinner>(Resource.Id.mSystemType); for (int i = 0; i < SystemSpinner.Count; i++) { if (SystemSpinner.GetItemAtPosition(i).ToString() == sdr["SystemType"].ToString()) { id = i; break; } } SystemSpinner.SetSelection(id, true); sdr.Close(); } } else { CommonFunction.ShowMessage("数据库打开失败!", this, true); } } catch (Exception ex) { CommonFunction.ShowMessage("数据库创建失败!", this, true); } finally { if (conn.State != System.Data.ConnectionState.Closed) { conn.Clone(); } conn.Dispose(); } #endregion } // 按钮事件 Button bLogin = FindViewById <Button>(Resource.Id.bLogin); bLogin.Click += bLogin_Click; TextView txt_Exit = FindViewById <TextView>(Resource.Id.textView4); txt_Exit.Click += textExit; TextView txt_Init = FindViewById <TextView>(Resource.Id.textView5); txt_Init.Click += textInit; #region try { IntentFilter ndef = new IntentFilter(NfcAdapter.ActionTagDiscovered); m_nfcAdapter = NfcAdapter.GetDefaultAdapter(this); m_nfcAdapter.SetNdefPushMessage(CreateNdefMessageCallback(), this, this); } catch (NullReferenceException nullex) { CommonFunction.ShowMessage(nullex.Message, this, true); } #endregion } catch (Exception ex) { CommonFunction.ShowMessage(ex.ToString(), this, true); } }
public NFCIntegration() { Context = Application.Context; NfcAdapter = NfcAdapter.GetDefaultAdapter(Context); }
protected override void OnStart() { base.OnStart(); nfcAdapter = NfcAdapter.GetDefaultAdapter(this); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); _nfcAdapter = NfcAdapter.GetDefaultAdapter(this); }
private int isOK = 0; //收发货标识 #endregion #region 创建Activity protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here SetContentView(Resource.Layout.InsideDish); //操作人 UserName = Intent.GetStringExtra("username"); username = FindViewById <EditText>(Resource.Id.username); username.Text = UserName; btGet = FindViewById <ToggleButton>(Resource.Id.btGet); btGet.Enabled = false; btGet.Click += getDb; btSender = FindViewById <ToggleButton>(Resource.Id.btSet); btSender.Enabled = false; btSender.Click += sendDb; btSave = FindViewById <ToggleButton>(Resource.Id.btSave); btSave.Enabled = true; btSave.Checked = true; btSave.Click += dbSave; if (CommonFunction.mode == "NFC") { #region NFC 模式 try { m_nfcAdapter = NfcAdapter.GetDefaultAdapter(this); if (m_nfcAdapter == null) { CommonFunction.ShowMessage("设备不支持NFC!", this, true); return; } if (!m_nfcAdapter.IsEnabled) { CommonFunction.ShowMessage("请在系统设置中先启用NFC功能!", this, true); return; } //m_nfcAdapter.SetNdefPushMessage(CreateNdefMessageCallback(), this, this); mTechLists = new string[][] { new string[] { "Android.Nfc.Tech.MifareClassic" }, new string[] { "Android.Nfc.Tech.NfcA" } }; IntentFilter tech = new IntentFilter(NfcAdapter.ActionTechDiscovered); mFilters = new IntentFilter[] { tech, }; //存放支持technologies的数组 mPendingIntent = PendingIntent.GetActivity(this, 0, new Intent(this, typeof(InsideDish)).AddFlags(ActivityFlags.SingleTop), PendingIntentFlags.UpdateCurrent); //intent过滤器,过滤类型为NDEF_DISCOVERED //Mifare卡和Desfare卡都是ISO - 14443 - A卡 ProcessAdapterAction(this.Intent); } catch (Exception ex) { CommonFunction.ShowMessage(ex.Message, this, true); } #endregion } else if (CommonFunction.mode == "SerialPort") { #region SerialPort模式 try { Stream im; Stream om; serial = new SerialPort(13, 115200, 0); serial.Power_5Von(); im = serial.MFileInputStream; om = serial.MFileOutputStream; hf = new HfReader(im, om); } catch (Exception ex) { CommonFunction.ShowMessage(ex.Message, this, true); } #endregion } }
protected override void OnPause() { base.OnPause(); NfcAdapter.GetDefaultAdapter(this).DisableForegroundDispatch(this); }
/* * Constructor * Used to get the adapter of the current Activity context */ public NFC(Context context) { _nfcAdapter = NfcAdapter.GetDefaultAdapter(context); }
public NfcService() { var activity = CrossCurrentActivity.Current.Activity; _nfcDevice = NfcAdapter.GetDefaultAdapter(activity); }
private CardEmulation GetEmulation() { var nfcAdapter = NfcAdapter.GetDefaultAdapter(ApplicationContext); return(CardEmulation.GetInstance(nfcAdapter)); }
private void InitNFC() { mNfcAdapter = NfcAdapter.GetDefaultAdapter(this); }
protected void CreateMiscTests() { CategoryNames.Add("Miscellaneous Tests"); CreateTest("QR scanner", async() => { UpdateInfo("Testing..."); MobileBarcodeScanner.Initialize(Application); var scanner = new MobileBarcodeScanner() { UseCustomOverlay = true }; var customOverlay = LayoutInflater.FromContext(this).Inflate(Resource.Layout.QRoverlay, null); customOverlay.FindViewById <ImageButton>(Resource.Id.qr_flashlight_button).Click += (ob, ev) => { scanner.ToggleTorch(); }; customOverlay.FindViewById <ImageButton>(Resource.Id.qr_cancel_button).Click += (ob, ev) => { scanner.Cancel(); }; scanner.CustomOverlay = customOverlay; var opts = new MobileBarcodeScanningOptions() { AutoRotate = true, PossibleFormats = new List <BarcodeFormat> { BarcodeFormat.QR_CODE } }; var result = await scanner.Scan(opts); string msg = ""; if (result != null && !string.IsNullOrEmpty(result.Text)) { msg = "Found QR code: " + result.Text; } else { msg = "Scanning Canceled!"; } this.RunOnUiThread(() => Toast.MakeText(this, msg, ToastLength.Short).Show()); UpdateInfo($"Test complete. QR code: {result.Text ?? "(Scanning canceled by user)"}"); }); CreateTest("NFC Capability", async() => { UpdateInfo("Testing; pass device near an NFC tag."); var _nfcAdapter = NfcAdapter.GetDefaultAdapter(this); if (_nfcAdapter == null) { UpdateInfo("Test failed: this device doesn't seem to have NFC capability."); return; } signalFlag = new AsyncManualResetEvent(); // Create an intent filter for when an NFC tag is discovered. var tagDetected = new IntentFilter(NfcAdapter.ActionTagDiscovered); var filters = new[] { tagDetected }; // When an NFC tag is detected, Android will use the PendingIntent to come back to this activity. // The OnNewIntent method will be invoked by Android. var intent = new Intent(this, this.GetType()).AddFlags(ActivityFlags.SingleTop); var pendingIntent = PendingIntent.GetActivity(this, 0, intent, 0); Res.AllowNewActivities = false; _nfcAdapter.EnableForegroundDispatch(this, pendingIntent, filters, null); var token = SetupStopButtonOneShot("Test ended."); await Task.WhenAny(token.AsTask(), signalFlag.WaitAsync()); if (!token.IsCancellationRequested) { var text = resultView.Text; stopButton.CallOnClick(); while (cts != null) { await Task.Delay(25); } UpdateInfo(text); } }); CreateTest("Vibrate", async() => { UpdateInfo("Trying to vibrate..."); Plugin.Vibrate.CrossVibrate.Current.Vibration(1000); await Task.Delay(300); UpdateInfo("Test complete."); }); }