protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); EMDKResults results = EMDKManager.GetEMDKManager(Android.App.Application.Context, this); if (results.StatusCode != EMDKResults.STATUS_CODE.Success) { ScannerStatus = "Status: EMDKManager object creation failed ..."; } else { ScannerStatus = "Status: EMDKManager object creation succeeded ..."; } Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); app = new App(); LoadApplication(app); }
private void initializeEMDK() { if (mEMDKManager == null) { EMDKResults results = null; try { //The EMDKManager object will be created and returned in the callback. results = EMDKManager.GetEMDKManager(mContext.ApplicationContext, mEMDKListener); } catch (Exception e) { logMessage("Error while requesting EMDKManager.\n" + e.Message, EMessageType.ERROR); return; } //Check the return status of EMDKManager object creation. if (results.StatusCode == EMDKResults.STATUS_CODE.Success) { logMessage("EMDKManager request command issued with success", EMessageType.DEBUG); } else { logMessage("EMDKManager request command error", EMessageType.ERROR); } } else { onEMDKManagerRetrieved(mEMDKManager); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); EMDKResults result = EMDKManager.GetEMDKManager(Application.Context, this); if (result.StatusCode != EMDKResults.STATUS_CODE.Success) { Toast.MakeText(this, "Error opening the EMDK Manager", ToastLength.Long).Show(); } else { Toast.MakeText(this, "EMDK Manager is available", ToastLength.Long).Show(); } ScanReceiver _broadcastReceiver = new ScanReceiver(); global::Xamarin.Forms.Forms.Init(this, bundle); var my_application = new App(); _broadcastReceiver.scanDataReceived += (s, scanData) => { MessagingCenter.Send <App, string> (my_application, "ScanBarcode", scanData); }; // Register the broadcast receiver IntentFilter filter = new IntentFilter(ScanReceiver.IntentAction); filter.AddCategory(ScanReceiver.IntentCategory); Android.App.Application.Context.RegisterReceiver(_broadcastReceiver, filter); LoadApplication(my_application); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); statusTextView = FindViewById <TextView>(Resource.Id.textViewStatus) as TextView; checkBoxCode128 = FindViewById <CheckBox>(Resource.Id.checkBoxCode128); checkBoxCode39 = FindViewById <CheckBox>(Resource.Id.checkBoxCode39); checkBoxEAN8 = FindViewById <CheckBox>(Resource.Id.checkBoxEAN8); checkBoxEAN13 = FindViewById <CheckBox>(Resource.Id.checkBoxEAN13); checkBoxUPCA = FindViewById <CheckBox>(Resource.Id.checkBoxUPCE); checkBoxUPCE0 = FindViewById <CheckBox>(Resource.Id.checkBoxUPCE0); // Set listener to the button AddSetButtonListener(); // The EMDKManager object will be created and returned in the callback EMDKResults results = EMDKManager.GetEMDKManager(Android.App.Application.Context, this); // Check the return status of processProfile if (results.StatusCode != EMDKResults.STATUS_CODE.Success) { // EMDKManager object initialization success statusTextView.Text = "EMDKManager object creation failed ..."; } else { // EMDKManager object initialization failed statusTextView.Text = "EMDKManager object creation succeeded ..."; } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Symbol.XamarinEMDK.SerialCommSample1.Resource.Layout.Main); editText = FindViewById <EditText>(Symbol.XamarinEMDK.SerialCommSample1.Resource.Id.editText1); editText.SetText("Serial Communication Write Data Testing.", EditText.BufferType.Normal); statusView = FindViewById <TextView>(Symbol.XamarinEMDK.SerialCommSample1.Resource.Id.statusView); statusView.SetText("", TextView.BufferType.Normal); statusView.RequestFocus(); EMDKResults results = EMDKManager.GetEMDKManager(ApplicationContext, this); if (results.StatusCode != EMDKResults.STATUS_CODE.Success) { statusView.SetText("Failed to open EMDK", TextView.BufferType.Normal); } else { statusView.SetText("Opening EMDK...", TextView.BufferType.Normal); } addReadButtonEvents(); writeButtonEvents(); setEnabled(false); Activity = this; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); textViewData = FindViewById <TextView>(Resource.Id.textViewData) as TextView; textViewStatus = FindViewById <TextView>(Resource.Id.textViewStatus) as TextView; AddStartScanButtonListener(); AddStopScanButtonListener(); AddSpinnerScannersListener(); AddSpinnerTriggersListener(); AddCheckBoxContinuousListener(); AddCheckBoxDecodersListener(); PopulateTriggers(); // The EMDKManager object will be created and returned in the callback EMDKResults results = EMDKManager.GetEMDKManager(Application.Context, this); // Check the return status of GetEMDKManager if (results.StatusCode != EMDKResults.STATUS_CODE.Success) { // EMDKManager object initialization success textViewStatus.Text = "Status: EMDKManager object creation failed."; } else { // EMDKManager object initialization failed textViewStatus.Text = "Status: EMDKManager object creation succeeded."; } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); textViewStatus = FindViewById <TextView>(Resource.Id.PStextView); EMDKResults results = EMDKManager.GetEMDKManager(ApplicationContext, this); if (results.StatusCode != EMDKResults.STATUS_CODE.Success) { textViewStatus.Text = string.Empty; textViewStatus.SetText("Status: " + "Failed in getEMDKManager::" + results.StatusCode, TextView.BufferType.Normal); } else { textViewStatus.Text = string.Empty; textViewStatus.SetText("Status: " + "getEMDKManager Success", TextView.BufferType.Normal); } addCrdInfoButtonListener(); addbtnUnlockButtonListener(); addFlashLedsButtonListener(); addFCCheckboxListener(); addDiagnosticButtonListener(); }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Log.Debug(TAG, "SSC onCreate"); // getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); results = EMDKManager.GetEMDKManager(Activity.ApplicationContext, this); }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); EMDKResults result = EMDKManager.GetEMDKManager(Android.App.Application.Context, this); if (result.StatusCode != EMDKResults.STATUS_CODE.Success) { Toast.MakeText(this, "Error opening the EMDK Manager", ToastLength.Long).Show(); } else { Toast.MakeText(this, "EMDK Manager is available", ToastLength.Long).Show(); } _broadcastReceiver = new ScanReceiver(); Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); var my_application = new App(); _broadcastReceiver.scanDataReceived += (s, scanData) => { MessagingCenter.Send <App, string>(my_application, "ScanBarcode", scanData); }; LoadApplication(my_application); }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); Scanner = DependencyService.Get <ScannerService>(); var results = EMDKManager.GetEMDKManager(Android.App.Application.Context, Scanner); if (results.StatusCode != EMDKResults.STATUS_CODE.Success) { //statusView.Text = "Status: EMDKManager object creation failed ..."; } else { //statusView.Text = "Status: EMDKManager object creation succeeded ..."; } //App application = new App(); App.Scanner = Scanner; LoadApplication(new App()); }
public override void OnViewCreated(View view, Bundle savedInstanceState) { base.OnViewCreated(view, savedInstanceState); menuRed = view.FindViewById <FloatingActionMenu> (Resource.Id.menu_red); fab1 = view.FindViewById <FloatingActionButton> (Resource.Id.fab1); fab2 = view.FindViewById <FloatingActionButton> (Resource.Id.fab2); fab3 = view.FindViewById <FloatingActionButton> (Resource.Id.fab3); statusView = view.FindViewById <TextView>(Resource.Id.statusView); dataView = view.FindViewById <TextView>(Resource.Id.DataView); ContextThemeWrapper context = new ContextThemeWrapper(this.Activity, Resource.Style.MenuButtonsStyle); FloatingActionButton programFab2 = new FloatingActionButton(context); EMDKResults results = EMDKManager.GetEMDKManager(Application.Context, this); if (results.StatusCode != EMDKResults.STATUS_CODE.Success) { statusView.Text = "Status: EMDKManager object creation failed ..."; } else { statusView.Text = "Status: EMDKManager object creation succeeded ..."; } programFab2.LabelText = "Programmatically added button"; programFab2.SetImageResource(Resource.Drawable.ic_edit); fab1.Enabled = false; menuRed.SetOnMenuButtonClickListener(this); menuRed.SetClosedOnTouchOutside(true); menuRed.HideMenuButton(false); ; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); getImagesOferta(); buscarLoyal = (Button)FindViewById(Resource.Id.recompensa_btn); buscarLoyal.Click += dialogLoyal; EMDKResults results = EMDKManager.GetEMDKManager(Android.App.Application.Context, this); if (results.StatusCode != EMDKResults.STATUS_CODE.Success) { ScannerStatus = "Status: EMDKManager object creation failed ..."; } else { ScannerStatus = "Status: EMDKManager object creation succeeded ..."; } StartTimer(); }
void InitializeEMDK(Context context) { var results = EMDKManager.GetEMDKManager(context, this); if (results.StatusCode != EMDKResults.STATUS_CODE.Success) { throw new InvalidOperationException("Unable to initialize EMDK Manager"); } }
private void btnRequestPermissionClick(object sender, EventArgs e) { EMDKResults emdkManagerResults = EMDKManager.GetEMDKManager(Application.Context, this); if (emdkManagerResults.StatusCode != EMDKResults.STATUS_CODE.Success) { Log.Error(LOG_TAG, "Unable to create EMDK Manager"); Toast.MakeText(this, "Unable to create EMDK Manager", ToastLength.Short).Show(); } }
public ScannerEmdk(EMDKManager.IEMDKListener listener) { Log.Debug(TAG, "scannerUtil is initialized"); //The EMDKManager object will be created asynchronously, and returned in OnOpen callback. EMDKResults results = EMDKManager.GetEMDKManager(Android.App.Application.Context, listener); if (results.StatusCode != EMDKResults.STATUS_CODE.Success) { throw new Exception("Barcode scanner could not be initialized."); } }
void InitializeEMDK(Context context) { // To retrieve the EMDKManager correctly this code requires // an instance of EMDKMAnager.IEMDKListener which is why // we can pass the current instance via 'this' EMDKResults results = EMDKManager.GetEMDKManager(context, this); if (results.StatusCode != EMDKResults.STATUS_CODE.Success) { // If there is a problem initializing throw an exception throw new InvalidOperationException("Unable to initialize EMDK Manager"); } }
public bool Initialize() { var wasSuccessful = false; try { var results = EMDKManager.GetEMDKManager(Android.App.Application.Context, this); wasSuccessful = results.StatusCode == EMDKResults.STATUS_CODE.Success; } catch (Exception ex) { wasSuccessful = false; System.Diagnostics.Debug.WriteLine(ex); } return(wasSuccessful); }
public void EnciendeEscaner() { EMDKResults results = EMDKManager.GetEMDKManager(Android.App.Application.Context, this); if (results.StatusCode != EMDKResults.STATUS_CODE.Success) { // EMDKManager object initialization success Console.WriteLine("Main", "Status: EMDKManager object creation failed."); } else { // EMDKManager object initialization failed Console.WriteLine("Main", "Status: EMDKManager object creation succeeded."); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); present_Activity = this; SetContentView(Resource.Layout.Main); /*tableView = FindViewById<TableLayout>(Resource.Id.tableView); * scrollView = FindViewById<ScrollView>(Resource.Id.scrollView); * textViewStatus = FindViewById<TextView>(Resource.Id.textViewStatus) as TextView; * textView = (TextView) FindViewById<TextView>(Resource.Id.textView); * textView1 = FindViewById<TextView>(Resource.Id.textView1) as TextView; * textView2 = FindViewById<TextView>(Resource.Id.textView2) as TextView; * textView4 = FindViewById<TextView>(Resource.Id.textView4) as TextView; * textViewType = FindViewById<TextView>(Resource.Id.textViewType) as TextView; * * spinnerScannerDevices = FindViewById<Spinner>(Resource.Id.spinnerScannerDevices) as Spinner; * spinnerTriggers = FindViewById<Spinner>(Resource.Id.spinnerTriggers); * barcodeCount = FindViewById<EditText>(Resource.Id.barcodeCount); * Button StartScanbtn = FindViewById<Button>(Resource.Id.buttonStartScan);*/ textViewStatus = (TextView)FindViewById(Resource.Id.textViewStatus); spinnerScannerDevices = (Spinner)FindViewById(Resource.Id.spinnerScannerDevices); spinnerTriggers = (Spinner)FindViewById(Resource.Id.spinnerTriggers); barcodeCount = (EditText)FindViewById(Resource.Id.barcodeCount); barcodeCount.TextChanged += BarcodeCount_TextChanged; EMDKResults results = EMDKManager.GetEMDKManager(Application.Context, this); // Check the return status of GetEMDKManager if (results.StatusCode != EMDKResults.STATUS_CODE.Success) { // EMDKManager object initialization failed textViewStatus.Text = "Status: EMDKManager object creation failed."; } else { // EMDKManager object initialization succeeded textViewStatus.Text = "Status: EMDKManager object creation succeeded."; } AddBarcodeCountListener(); AddStartScanButtonListener(); AddSpinnerScannerDevicesListener(); AddSpinnerTriggersListener(); PopulateTriggers(); }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); //Ring Scanner related EMDKResults results = EMDKManager.GetEMDKManager(Android.App.Application.Context, this); RequestedOrientation = ScreenOrientation.Portrait; }
private void getEMDKManager() { string strResults = string.Empty; EMDKResults results = EMDKManager.GetEMDKManager(Application.Context, this); if (results.StatusCode != EMDKResults.STATUS_CODE.Success) { strResults = "EMDKManager object creation failed!"; } else { strResults = "EMDKManager object creation succeeded."; } OnStatusChanged?.Invoke(this, new EMDKStatusChangedArgs(strResults)); }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); var setup = new Setup(); setup.Initialize(); Scanner = Resolver.Locator.Resolve <ScannerService>(); EMDKManager.GetEMDKManager(Android.App.Application.Context, Scanner); App.Scanner = Scanner; LoadApplication(new App()); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); EMDKResults result = EMDKManager.GetEMDKManager(Application.Context, this); if (result.StatusCode != EMDKResults.STATUS_CODE.Success) { Toast.MakeText(this, "Error opening the EMDK Manager", ToastLength.Long).Show(); } else { Toast.MakeText(this, "EMDK Manager is available", ToastLength.Long).Show(); } // Get our button from the layout resource, // and attach an event to toggle scanning option Button scanButton = FindViewById <Button>(Resource.Id.btn_scan); scanButton.Click += delegate { var intent = new Intent(); intent.SetAction(ACTION_SOFTSCANTRIGGER); intent.PutExtra(EXTRA_PARAM, DWAPI_TOGGLE_SCANNING); SendBroadcast(intent); }; MyReceiver _broadcastReceiver = new MyReceiver(); EditText editText = FindViewById <EditText>(Resource.Id.editbox); _broadcastReceiver.scanDataReceived += (s, scanData) => { editText.Text = scanData; }; // Register the broadcast receiver IntentFilter filter = new IntentFilter("barcodescanner.RECVR"); filter.AddCategory("android.intent.category.DEFAULT"); Application.Context.RegisterReceiver(_broadcastReceiver, filter); }
//ScanAndPairManager.StatusEventArgs statusCallbackObj = this; protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); btName = FindViewById <EditText>(Resource.Id.name); btAddress = (EditText)FindViewById(Resource.Id.address); checkBoxAlwaysScan = (CheckBox)FindViewById(Resource.Id.alwaysscan); checkboxHardTrigger = (CheckBox)FindViewById(Resource.Id.triggerType); scanAndPairButton = (Button)FindViewById(Resource.Id.scanandpair); scanAndUnpairButton = (Button)FindViewById(Resource.Id.scanandunpair); statusView = (TextView)FindViewById(Resource.Id.logs); scandataType = (Spinner)FindViewById(Resource.Id.scanDataType); statusView.SetText("\n", TextView.BufferType.Normal); btName.Enabled = false; btAddress.Enabled = false; // The EMDKManager object creation and object will be returned in the callback. EMDKResults results = EMDKManager.GetEMDKManager(ApplicationContext, this); // Check the return status of getEMDKManager () if (results.StatusCode == EMDKResults.STATUS_CODE.Success) { statusView.SetText("Please wait, initialization in progress...", TextView.BufferType.Normal); } else { statusView.SetText("Initialization failed!", TextView.BufferType.Normal); } System.Collections.Generic.List <Symbol.XamarinEMDK.ScanAndPair.ScanAndPairConfig.ScanDataType> scanDataTypes = new System.Collections.Generic.List <ScanAndPairConfig.ScanDataType>(); scanDataTypes.Add(Symbol.XamarinEMDK.ScanAndPair.ScanAndPairConfig.ScanDataType.MacAddress); scanDataTypes.Add(Symbol.XamarinEMDK.ScanAndPair.ScanAndPairConfig.ScanDataType.DeviceName); scanDataTypes.Add(Symbol.XamarinEMDK.ScanAndPair.ScanAndPairConfig.ScanDataType.Unspecified); ArrayAdapter <Symbol.XamarinEMDK.ScanAndPair.ScanAndPairConfig.ScanDataType> arrayAdapter = new ArrayAdapter <Symbol.XamarinEMDK.ScanAndPair.ScanAndPairConfig.ScanDataType>(ApplicationContext, Resource.Layout.simple_spinner_item, scanDataTypes); scandataType.Adapter = arrayAdapter; registerForButtonEvents(); addCheckBoxListener(); }
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 mStatusTextView = FindViewById <TextView>(Resource.Id.textViewStatus); mDataView = FindViewById <EditText>(Resource.Id.editText1); // Now the EMDKManager! EMDKResults result = EMDKManager.GetEMDKManager(Application.Context, this); if (result.StatusCode != EMDKResults.STATUS_CODE.Success) { mStatusTextView.Text = "EMDKManager Request failed!"; } }
private void setUpZebraScanner() { try { EMDKResults results = EMDKManager.GetEMDKManager(Android.App.Application.Context, this); if (results.StatusCode != EMDKResults.STATUS_CODE.Success) { Console.WriteLine("Status: EMDKManager object creation failed ..."); } else { Console.WriteLine("Status: EMDKManager object creation succeeded ..."); Toast.MakeText(Android.App.Application.Context, "Scan a cdb qrid at any time using the built in scanner.", ToastLength.Long).Show(); Toast.MakeText(Android.App.Application.Context, "Scan a cdb qrid at any time using the built in scanner.", ToastLength.Long).Show(); } } catch (Exception e) { Console.WriteLine(e); } }
protected override void OnCreate(Bundle savedInstanceState) { try { base.OnCreate(savedInstanceState); Window.SetFlags(WindowManagerFlags.KeepScreenOn, WindowManagerFlags.KeepScreenOn); SetContentView(Resource.Layout.activity_main); numberTNForOrderlist = (TextView)FindViewById(Resource.Id.numberTNForOrderlist); ordersRecyclerView = (RecyclerView)FindViewById(Resource.Id.ordersRecyclerView); buttonRemove = (ImageButton)FindViewById(Resource.Id.buttonRemove); buttonAplay = (ImageButton)FindViewById(Resource.Id.buttonAplay); toolbarInputData = (Android.Support.V7.Widget.Toolbar)FindViewById(Resource.Id.toolbarInputData); codeInput = (EditText)FindViewById(Resource.Id.codeInput); weightInput = (EditText)FindViewById(Resource.Id.weightInput); quentityInput = (EditText)FindViewById(Resource.Id.quentityInput); radioGroupFiltering = (RadioGroup)FindViewById(Resource.Id.radioGroupFiltering); radioButtonAll = (RadioButton)FindViewById(Resource.Id.radioButtonAll); radioButtonDef = (RadioButton)FindViewById(Resource.Id.radioButtonDef); try { var results = EMDKManager.GetEMDKManager(Application.Context, this); } catch { } buttonAplay.Click += ButtonAplay_Click; buttonRemove.Click += ButtonRemove_Click; radioButtonAll.Click += RadioButtonAll_Click; radioButtonDef.Click += RadioButtonDef_Click; InitializingOrdersList(); isEdit = false; isShortList = false; } catch (Exception ex) { ErrorMessage("MainActivity - OnCreate :" + ex.Message); } }
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 bundle) { base.OnCreate(bundle); // Disable auto rotation of the app. RequestedOrientation = Android.Content.PM.ScreenOrientation.Nosensor; // Get current rotation angle of the screen from its default/natural orientation. var windowManager = (IWindowManager)ApplicationContext.GetSystemService(Context.WindowService).JavaCast <IWindowManager>(); var rotation = windowManager.DefaultDisplay.Rotation; // Determine width/height in pixels based on the rotation angle. DisplayMetrics dm = new DisplayMetrics(); WindowManager.DefaultDisplay.GetMetrics(dm); int width = 0; int height = 0; switch (rotation) { case SurfaceOrientation.Rotation0: width = dm.WidthPixels; height = dm.HeightPixels; break; case SurfaceOrientation.Rotation90: case SurfaceOrientation.Rotation270: width = dm.WidthPixels; height = dm.HeightPixels; break; default: break; } // Set corresponding layout dynamically based on the default/natural orientation. if (width > height) { SetContentView(Resource.Layout.Landscape); horizontal = true; } else { SetContentView(Resource.Layout.Portrait); } textViewData = FindViewById <TextView>(Resource.Id.textViewData) as TextView; textViewStatus = FindViewById <TextView>(Resource.Id.textViewStatus) as TextView; buttonStartScan = FindViewById <Button>(Resource.Id.buttonStartScan); buttonStartScan.Click += buttonStartScan_Click; buttonStopScan = FindViewById <Button>(Resource.Id.buttonStopScan); buttonStopScan.Click += buttonStopScan_Click; if (horizontal) { buttonStartScan.SetWidth(120); buttonStartScan.SetTextKeepState("Start", TextView.BufferType.Editable); buttonStopScan.SetWidth(120); buttonStopScan.SetTextKeepState("Stop", TextView.BufferType.Editable); } // AddStartScanButtonListener(); AddSpinnerScannersListener(); AddSpinnerTriggersListener(); AddCheckBoxContinuousListener(); AddCheckBoxDecodersListener(); PopulateTriggers(); // The EMDKManager object will be created and returned in the callback EMDKResults results = EMDKManager.GetEMDKManager(Application.Context, this); // Check the return status of GetEMDKManager if (results.StatusCode != EMDKResults.STATUS_CODE.Success) { // EMDKManager object initialization failed textViewStatus.Text = "Status: EMDKManager object creation failed."; } else { // EMDKManager object initialization succeeded textViewStatus.Text = "Status: EMDKManager object creation succeeded."; } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Disable auto rotation of the app. RequestedOrientation = Android.Content.PM.ScreenOrientation.Nosensor; // Get current rotation angle of the screen from its default/natural orientation. var windowManager = (IWindowManager)ApplicationContext.GetSystemService(Context.WindowService).JavaCast <IWindowManager>(); var rotation = windowManager.DefaultDisplay.Rotation; // Determine width/height in pixels based on the rotation angle. DisplayMetrics dm = new DisplayMetrics(); WindowManager.DefaultDisplay.GetMetrics(dm); int width = 0; int height = 0; switch (rotation) { case SurfaceOrientation.Rotation0: width = dm.WidthPixels; height = dm.HeightPixels; break; case SurfaceOrientation.Rotation90: case SurfaceOrientation.Rotation270: width = dm.WidthPixels; height = dm.HeightPixels; break; default: break; } // Set corresponding layout dynamically based on the default/natural orientation. if (width > height) { SetContentView(Resource.Layout.Landscape_Layout); } else { SetContentView(Resource.Layout.Portrait_Layout); } statusTextView = FindViewById(Resource.Id.textViewStatus) as TextView; wifiRadioEnable = FindViewById(Resource.Id.radio0) as RadioButton; wifiRadioDisable = FindViewById(Resource.Id.radio1) as RadioButton; ActionSpinner = FindViewById(Resource.Id.spinner1) as Spinner; ssidEditText = FindViewById(Resource.Id.editTextSSID) as EditText; AddSetButtonListener(); EMDKResults results = EMDKManager.GetEMDKManager(Application.Context, this); // Check the return status of processProfile if (results.StatusCode != EMDKResults.STATUS_CODE.Success) { // EMDKManager object initialization failed statusTextView.Text = "EMDKManager object creation failed ..."; } else { // EMDKManager object initialization succeeded statusTextView.Text = "EMDKManager object creation succeeded ..."; } }