// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { global::Xamarin.Forms.Forms.Init(); LoadApplication(new App(BluetoothLowEnergyAdapter.ObtainDefaultAdapter())); return(base.FinishedLaunching(app, options)); }
protected override void OnCreate(Bundle savedInstanceState) { Instance = this; //这里设置TabbedPage选中颜色 TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; //初始化UITest AppCenter.Start("6be9c596-5920-47cc-bac1-cd2a5b3709b5", typeof(Analytics), typeof(Crashes)); //初始化弹窗 Rg.Plugins.Popup.Popup.Init(this, savedInstanceState); //初始化takephoto CrossCurrentActivity.Current.Init(this, savedInstanceState); //初始化蓝牙 //BluetoothLowEnergyAdapter.InitActivity( this ); IBluetoothLowEnergyAdapter bleAdapter = null; BluetoothLowEnergyAdapter.Init(this); bleAdapter = BluetoothLowEnergyAdapter.ObtainDefaultAdapter(ApplicationContext); base.OnCreate(savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); LoadApplication(new App(bleAdapter)); }
public override Boolean FinishedLaunching(UIApplication app, NSDictionary options) { Forms.Init(); LoadApplication(new FormsApp(BluetoothLowEnergyAdapter.ObtainDefaultAdapter())); return(base.FinishedLaunching(app, options)); }
// This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and make window visible // NOTE: You have 17 seconds to return from this method or iOS will terminate application public override bool FinishedLaunching( UIApplication app, NSDictionary options) { global::Xamarin.Forms.Forms.Init(); //Distribute.DontCheckForUpdatesInDebug(); // Get Intun Parameters //Online.DownloadIntuneParameters (); //Parameters.PrepareFromIntune(); // Core Foundation Keys: // https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html var appVersion = NSBundle.MainBundle.InfoDictionary["CFBundleShortVersionString"]; var appBuild = NSBundle.MainBundle.InfoDictionary["CFBundleVersion"]; IBluetoothLowEnergyAdapter bluetoothLowEnergyAdapter = BluetoothLowEnergyAdapter.ObtainDefaultAdapter(); IUserDialogs userDialogs = UserDialogs.Instance; string appversion = appVersion.Description + " ( " + appBuild.Description + " )"; appSave = new FormsApp(bluetoothLowEnergyAdapter, userDialogs, appversion); // Check if FTP settings is in securestorage GenericUtilsClass.CheckFTPDownload(); //TEST.Test (); base.LoadApplication(appSave); return(base.FinishedLaunching(app, options)); }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { var color = UIColor.FromRGB(128, 188, 0); UITabBar.Appearance.SelectedImageTintColor = color; //settings tab selected color UINavigationBar.Appearance.BarTintColor = color; //background of navbar UISwitch.Appearance.TintColor = color; UISwitch.Appearance.OnTintColor = color; UINavigationBar.Appearance.TintColor = UIColor.White; //menu icon color //UINavigationBar.Appearance.BackgroundColor = UIColor.Purple; UINavigationBar.Appearance.SetTitleTextAttributes(new UITextAttributes() { TextColor = UIColor.White }); //TODO: this should be done in xamarin forms //https://forums.xamarin.com/discussion/19277/how-to-change-xamarin-form-navigationpage-title-color Rg.Plugins.Popup.Popup.Init(); IBluetoothLowEnergyAdapter bleAdapter = null; bleAdapter = BluetoothLowEnergyAdapter.ObtainDefaultAdapter(); global::Xamarin.Forms.Forms.Init(); LoadApplication(new App(bleAdapter)); return(base.FinishedLaunching(app, options)); }
public MainPage() { this.InitializeComponent(); IBluetoothLowEnergyAdapter ble = BluetoothLowEnergyAdapter.ObtainDefaultAdapter(); LoadApplication(new MicD.App(ble)); }
public override bool OpenUrl( UIApplication app, NSUrl url, NSDictionary options) { appSave.HandleUrl(( Uri )url, BluetoothLowEnergyAdapter.ObtainDefaultAdapter()); return(true); }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { global::Xamarin.Forms.Forms.Init(); FormsMaterial.Init(); CachedImageRenderer.Init(); LoadApplication(new App(BluetoothLowEnergyAdapter.ObtainDefaultAdapter())); UIApplication.SharedApplication.SetStatusBarStyle(UIStatusBarStyle.LightContent, false); return(base.FinishedLaunching(app, options)); }
protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); BluetoothLowEnergyAdapter.Init(this); Xamarin.Forms.Forms.Init(this, bundle); var bluetooth = BluetoothLowEnergyAdapter.ObtainDefaultAdapter(ApplicationContext); LoadApplication(new App(bluetooth)); }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this, savedInstanceState); BluetoothLowEnergyAdapter.Init(this); var ble = BluetoothLowEnergyAdapter.ObtainDefaultAdapter(ApplicationContext); LoadApplication(new App(ble)); }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); if ((int)Build.VERSION.SdkInt >= 23) { string[] permissions = { Manifest.Permission.AccessCoarseLocation, Manifest.Permission.AccessFineLocation }; if (CheckSelfPermission(permissions[0]) != (int)Permission.Granted || CheckSelfPermission(permissions[1]) != (int)Permission.Granted) { using (var builder = new AlertDialog.Builder(this)) { builder.SetMessage("Often android OEMs bundle bluetooth functionality with location, bluetooth doesn't work without it. Your location is never tracked."); builder.SetPositiveButton("OK", OkAction); var disclaimer = builder.Create(); disclaimer.Show(); } void OkAction(object sender, DialogClickEventArgs e) { ActivityCompat.RequestPermissions(this, permissions, 0); } } } //Set UI to Full Screen SetImmersiveUI(); //This line is required to Enable/Disable Bluetooth try { BluetoothLowEnergyAdapter.Init(this); } catch (Exception ex) { Log.Debug("RoverControl", ex.Message); } //Get Bluetooth adapter var bluetoothAdapter = BluetoothLowEnergyAdapter.ObtainDefaultAdapter(ApplicationContext); //Initialize ACR UserDialogs UserDialogs.Init(this); Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); LoadApplication(new App(bluetoothAdapter)); }
protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); BluetoothLowEnergyAdapter.Init(this); UserDialogs.Init(this); Forms.Init(this, bundle); LoadApplication( new FormsApp(BluetoothLowEnergyAdapter.ObtainDefaultAdapter(ApplicationContext), UserDialogs.Instance)); }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); UserDialogs.Init(this); _bleServer = new BleServer(this.ApplicationContext); var bluetooth = BluetoothLowEnergyAdapter.ObtainDefaultAdapter(ApplicationContext); LoadApplication(new App(bluetooth, UserDialogs.Instance)); }
protected override void OnMAMCreate(Bundle bundle) { //TabLayoutResource = Resource.Layout.Tabbar; // ToolbarResource = Resource.Layout.Toolbar; base.OnMAMCreate(bundle); UserDialogs.Init(this); global::Xamarin.Forms.Forms.Init(this, bundle); try { // If you want to enable/disable the Bluetooth adapter from code, you must call this. BluetoothLowEnergyAdapter.Init(this); }catch (Exception e) { Utils.Print(e.StackTrace); } // Obtain the bluetooth adapter so we can pass it into our (shared-code) Xamarin Forms app. There are // additional Obtain() methods on BluetoothLowEnergyAdapter if you have more specific needs (e.g. if you // need to support devices with multiple Bluetooth adapters) var bluetooth = BluetoothLowEnergyAdapter.ObtainDefaultAdapter(ApplicationContext); if (Xamarin.Forms.Device.Idiom == TargetIdiom.Phone) { RequestedOrientation = ScreenOrientation.Portrait; } else { RequestedOrientation = ScreenOrientation.Landscape; } //CrossCurrentActivity.Current.Init(this, bundle); var context = Android.App.Application.Context; var info = context.PackageManager.GetPackageInfo(context.PackageName, 0); string value = info.VersionName.ToString(); // Check if FTP settings is in securestorage GenericUtilsClass.CheckFTPDownload(); LoadApplication(new FormsApp(bluetooth, UserDialogs.Instance, value)); }
protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); UserDialogs.Init(this); Forms.Init(this, bundle); // If you want to enable/disable the Bluetooth adapter from code, you must call this. BluetoothLowEnergyAdapter.Init(this); // Obtain the bluetooth adapter so we can pass it into our (shared-code) Xamarin Forms app. There are // additional Obtain() methods on BluetoothLowEnergyAdapter if you have more specific needs (e.g. if you // need to support devices with multiple Bluetooth adapters) var bluetooth = BluetoothLowEnergyAdapter.ObtainDefaultAdapter(ApplicationContext); LoadApplication(new FormsApp(bluetooth, UserDialogs.Instance)); }
// This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and make window visible // NOTE: You have 17 seconds to return from this method or iOS will terminate application public override bool FinishedLaunching( UIApplication app, NSDictionary options) { global::Xamarin.Forms.Forms.Init(); //Distribute.DontCheckForUpdatesInDebug(); // Get Intun Parameters //var Mode = GenericUtilsClass.ChekInstallMode(); //if (Mode.Equals("None")) //{ // MAMService.LoginUserMAM(); // Thread.Sleep(2000); //} //Online.DownloadIntuneParameters (); //Parameters.PrepareFromIntune(); // Core Foundation Keys: // https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html var appVersion = NSBundle.MainBundle.InfoDictionary["CFBundleShortVersionString"]; var appBuild = NSBundle.MainBundle.InfoDictionary["CFBundleVersion"]; IBluetoothLowEnergyAdapter bluetoothLowEnergyAdapter = BluetoothLowEnergyAdapter.ObtainDefaultAdapter(); IUserDialogs userDialogs = UserDialogs.Instance; string appversion = appVersion.Description + " ( " + appBuild.Description + " )"; appSave = new FormsApp(bluetoothLowEnergyAdapter, userDialogs, appversion); //string user = IntuneMAMEnrollmentManager.Instance.EnrolledAccount; //TEST.Test (); base.LoadApplication(appSave); return(base.FinishedLaunching(app, options)); }
protected override void OnMAMCreate(Bundle bundle) { //TabLayoutResource = Resource.Layout.Tabbar; // ToolbarResource = Resource.Layout.Toolbar; base.OnMAMCreate(bundle); UserDialogs.Init(this); global::Xamarin.Forms.Forms.Init(this, bundle); Xamarin.Essentials.Platform.Init(this, bundle); try { // If you want to enable/disable the Bluetooth adapter from code, you must call this. BluetoothLowEnergyAdapter.Init(this); } catch (Exception e) { Utils.Print(e.StackTrace); } // Obtain the bluetooth adapter so we can pass it into our (shared-code) Xamarin Forms app. There are // additional Obtain() methods on BluetoothLowEnergyAdapter if you have more specific needs (e.g. if you // need to support devices with multiple Bluetooth adapters) var bluetooth = BluetoothLowEnergyAdapter.ObtainDefaultAdapter(ApplicationContext); if (Xamarin.Forms.Device.Idiom == TargetIdiom.Phone) { RequestedOrientation = ScreenOrientation.Portrait; } else { RequestedOrientation = ScreenOrientation.Landscape; } // CrossCurrentActivity.Current.Init ( this, bundle ); var data = Intent.Data; // check if this intent is started via custom scheme link if (data != null) { if (data.Scheme == "aclara-mtu-programmer") { //accessCodeTextbox.Text = data.Host; } } // Set our view from the "main" layout resource //SetContentView(Resource.Layout.SplashScreen); Context context = Android.App.Application.Context; PackageInfo info = context.PackageManager.GetPackageInfo(context.PackageName, 0); string appversion = info.VersionName + " ( " + info.VersionCode + " )"; FormsApp app = new FormsApp(bluetooth, UserDialogs.Instance, appversion); LoadApplication(app); app.HandleUrl(new System.Uri(data.ToString()), bluetooth); }
/// <remarks> /// This must be implemented if you want to Subscribe() to IBluetoothLowEnergyAdapter.State to be notified when the /// bluetooth adapter state changes (i.e., it is enabled or disabled). If you don't care about that in your use-case, then /// you don't need to implement this -- you can still query the state of the adapter, the observable just won't work. See /// <see cref="IBluetoothLowEnergyAdapter.State" /> /// </remarks> protected override void OnMAMActivityResult(Int32 requestCode, Result resultCode, Intent data) { BluetoothLowEnergyAdapter.OnActivityResult(requestCode, resultCode, data); }
public MainPage() { InitializeComponent(); LoadApplication(new FormsApp(BluetoothLowEnergyAdapter.ObtainDefaultAdapter())); }
// Public methods public async Task <bool> Initialize(Activity activity, Context context, BLECommandsParser.cmdTableDel_t action) { bool ret = false; try { g_activity = activity; g_context = context; // Initialize bluetooth adapter BluetoothLowEnergyAdapter.Init(activity); // Obtain bluetooth adapter handler g_BLEAdapterObj = BluetoothLowEnergyAdapter.ObtainDefaultAdapter(context); // Enable BLE adapter in case it is disabled. Close application if user denie if (g_BLEAdapterObj.AdapterCanBeEnabled && g_BLEAdapterObj.CurrentState.IsDisabledOrDisabling()) { await g_BLEAdapterObj.EnableAdapter(); if (true == g_BLEAdapterObj.CurrentState.IsDisabledOrDisabling()) { Library.CloseApplication(activity); } } // Suscribe to receive BLE adapter state changes g_BLEAdapterObj_stateChangeObserver = OnBLEAdapter_StateChange; g_BLEAdapterObj.CurrentState.Subscribe(Observer.Create <EnabledDisabledState>(g_BLEAdapterObj_stateChangeObserver, null, null)); // Suscribe to receive Location adapter state changes g_LocationAdapterStateChangeObserver = new OnLocationAdapterStateChange(); activity.RegisterReceiver(g_LocationAdapterStateChangeObserver, new IntentFilter(LocationManager.ProvidersChangedAction)); // Enable location service permissions. Needed to make BLE device scan Permission permissionCheck = ContextCompat.CheckSelfPermission(activity, Manifest.Permission.AccessFineLocation); if (permissionCheck != Permission.Granted) { if (true == Android.Support.V4.App.ActivityCompat.ShouldShowRequestPermissionRationale(activity, Manifest.Permission.AccessFineLocation)) { Toast.MakeText(activity, "The permission to get BLE location data is required", ToastLength.Short).Show(); } else { activity.RequestPermissions(new String[] { Manifest.Permission.AccessCoarseLocation, Manifest.Permission.AccessCoarseLocation }, 1); } } else { Toast.MakeText(activity, "Location permissions already granted", ToastLength.Short).Show(); } // Get Location Manager and check for GPS & Network location services. Ask user to enable them if needed LocationManager lm = (LocationManager)context.GetSystemService(Context.LocationService); if (!lm.IsProviderEnabled(LocationManager.GpsProvider) || !lm.IsProviderEnabled(LocationManager.NetworkProvider)) { EventHandler <DialogClickEventArgs> ButtonClickCb = OnLocationMsgButtonClick; // Build the alert dialog Android.Support.V7.App.AlertDialog.Builder builder = new Android.Support.V7.App.AlertDialog.Builder(activity); builder.SetTitle("Location Services Not Active"); builder.SetMessage("Please enable Location Services and GPS"); builder.SetPositiveButton("OK", ButtonClickCb); Dialog alertDialog = builder.Create(); alertDialog.SetCanceledOnTouchOutside(false); alertDialog.Show(); } // Initialize BLE Commands Parser g_BLECommandsParserObj = new BLECommandsParser(); Library.cmdTable += action; ret = true; } catch (Exception) { } return(ret); }
protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); BluetoothLowEnergyAdapter.InitActivity(this); UserDialogs.Init(this); Forms.Init(this, bundle); new Timer().Schedule( new TimerAction( () => { RunOnUiThread( () => { if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.Bluetooth) != Permission.Granted) { if (ActivityCompat.ShouldShowRequestPermissionRationale(this, Manifest.Permission.Bluetooth)) { UserDialogs.Instance.Alert( "Yes should show rationale for Bluetooth", "ShouldShowRequestPermissionRationale"); } else { Log.Info("Requesting permission for Bluetooth"); ActivityCompat.RequestPermissions(this, new[] { Manifest.Permission.Bluetooth }, 24112); } } else { Log.Info("Already have permission for Bluetooth"); } if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.BluetoothAdmin) != Permission.Granted) { if (ActivityCompat.ShouldShowRequestPermissionRationale( this, Manifest.Permission.BluetoothAdmin)) { UserDialogs.Instance.Alert( "Yes should show rationale for BluetoothAdmin", "ShouldShowRequestPermissionRationale"); } else { Log.Info("Requesting permission for BluetoothAdmin"); ActivityCompat.RequestPermissions( this, new[] { Manifest.Permission.BluetoothAdmin }, 24113); } } else { Log.Info("Already have permission for BluetoothAdmin"); } }); }), 12000); LoadApplication(new FormsApp(BluetoothLowEnergyAdapter.ObtainDefaultAdapter(ApplicationContext))); }
/* Activity callbacks */ protected sealed override void OnActivityResult(Int32 requestCode, Result resultCode, Intent data) { // Invoke BLE Adapter Activity Result BluetoothLowEnergyAdapter.OnActivityResult(requestCode, resultCode, data); }
// This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and make window visible // NOTE: You have 17 seconds to return from this method or iOS will terminate application public override bool FinishedLaunching( UIApplication app, NSDictionary options) { global::Xamarin.Forms.Forms.Init(); //Distribute.DontCheckForUpdatesInDebug(); /* * IntuneMAMPolicyManager value = IntuneMAMPolicyManager.Instance; * NSDictionary dictionary = value.DiagnosticInformation; * * NSString[] keys = new NSString[]{new NSString("AppConfig")}; * * NSDictionary key= dictionary.GetDictionaryOfValuesFromKeys(keys); * * var ftp_username = new NSObject(); * var ftp_pathremotefile = new NSObject(); * var cert_file = new NSObject(); * var ftp_password = new NSObject(); * var ftp_host = new NSObject(); * * for (int i = 0, keyCount = (int)key.Count; i < keyCount; i++) * { * NSObject fields_values = key.ElementAt(i).Value; * * ftp_username = fields_values.ValueForKey(new NSString("ftp_username")); * ftp_pathremotefile = fields_values.ValueForKey(new NSString("ftp_pathremotefile")); * cert_file = fields_values.ValueForKey(new NSString("cert_file")); * ftp_password = fields_values.ValueForKey(new NSString("ftp_password")); * ftp_host = fields_values.ValueForKey(new NSString("ftp_host")); * * Console.WriteLine("ftp_username: {0}, ftp_pathremotefile: {1}, cert_file: {2}, ftp_password: {3}, ftp_host: {4}", * ftp_username, ftp_pathremotefile, cert_file, ftp_password, ftp_host ); * } * * List <string> listaDatos = new List<string>(); * * try{ * listaDatos.Add("ftp_username: "******"ftp_pathremotefile: " + ftp_pathremotefile); * }catch (Exception c1){} * * try{ * listaDatos.Add("cert_file: " + cert_file); * }catch (Exception c1) { } * * try{ * listaDatos.Add("ftp_password: "******"ftp_host: " + ftp_host); * }catch (Exception c1) { } */ List <string> listaDatos = new List <string>(); var AppVersion = NSBundle.MainBundle.InfoDictionary["CFBundleVersion"]; IBluetoothLowEnergyAdapter bluetoothLowEnergyAdapter = BluetoothLowEnergyAdapter.ObtainDefaultAdapter(); IUserDialogs userDialogs = UserDialogs.Instance; NSString appversion = (Foundation.NSString)AppVersion.Description; /* * appSave = new FormsApp ( * bluetoothLowEnergyAdapter, * userDialogs, * listaDatos, * appversion); */ appSave = new FormsApp( bluetoothLowEnergyAdapter, listaDatos, userDialogs, appversion); //appSave = new FormsApp(bluetoothLowEnergyAdapter); base.LoadApplication(appSave); return(base.FinishedLaunching(app, options)); }