// Sets up member variables related to camera. private void SetUpCameraOutputs(int width, int height) { CameraManager manager = (CameraManager)Activity.GetSystemService(Context.CameraService); try { foreach (string cameraId in manager.GetCameraIdList()) { CameraCharacteristics characteristics = manager.GetCameraCharacteristics(cameraId); Integer facing = (Integer)characteristics.Get(CameraCharacteristics.LensFacing); if (facing != null && facing == (Integer.ValueOf((int)LensFacing.Front))) { continue; } StreamConfigurationMap map = (StreamConfigurationMap)characteristics.Get(CameraCharacteristics.ScalerStreamConfigurationMap); if (map == null) { continue; } // For still image captures, we use the largest available size. Size largest = (Size)Collections.Max(Arrays.AsList(map.GetOutputSizes((int)ImageFormatType.Jpeg)), new CompareSizesByArea()); _imageReader = ImageReader.NewInstance(largest.Width, largest.Height, ImageFormatType.Jpeg, 2); _imageReader.SetOnImageAvailableListener(OnImageAvailableListener, BackgroundHandler); _sensorOrientation = (int)characteristics.Get(CameraCharacteristics.SensorOrientation); bool swapped = IsCameraRoationSameAsDevice(Activity.WindowManager.DefaultDisplay.Rotation, _sensorOrientation); Size rotatedSize = GetRotatedPreviewSize(width, height, swapped); Size maxSize = GetMaxPrieviewSize(width, height, swapped); // Danger, W.R.! Attempting to use too large a preview size could exceed the camera // bus' bandwidth limitation, resulting in gorgeous previews but the storage of // garbage capture data. _previewSize = ChooseOptimalSize(map.GetOutputSizes(Class.FromType(typeof(SurfaceTexture))), rotatedSize.Width, rotatedSize.Height, maxSize.Width, maxSize.Height, largest); SetTextureViewAspectRatio(); // Check if the flash is supported. Boolean available = (Boolean)characteristics.Get(CameraCharacteristics.FlashInfoAvailable); _flashSupported = (available == null ? false : (bool)available); _cameraId = cameraId; return; } } catch (CameraAccessException e) { e.PrintStackTrace(); } catch//camera_error { ErrorDialog.NewInstance(GetString(Resource.String.camera_error)).Show(ChildFragmentManager, FRAGMENT_DIALOG); } }
//****************** DYNAMIC VARIABLE CALLBACKS ******************* // Called when latest dynamic variables are loaded public void CTExperimentsUpdated() { RunOnUiThread(() => { Integer intval = cleverTapAPI.GetIntegerVariable("testint", new Java.Lang.Integer(1)); Java.Lang.Boolean boolVal = cleverTapAPI.GetBooleanVariable("testbool", new Java.Lang.Boolean(false)); Toast.MakeText(Android.App.Application.Context, "Experiments Updated[testInt-" + intval + " , Bool-" + boolVal + "]", ToastLength.Long).Show(); Log.Debug("CLEVERTAP", "Experiments Updated"); }); }
/// <summary> /// Finds the camera properties. /// </summary> /// <param name="defaultCamera">The default camera.</param> /// <exception cref="ArgumentOutOfRangeException">defaultCamera</exception> private void FindCameraProperties(CameraChoice defaultCamera) { switch (defaultCamera) { case CameraChoice.Rear: Helper(LensFacing.Back); break; case CameraChoice.Front: Helper(LensFacing.Front); break; default: throw new ArgumentOutOfRangeException(nameof(defaultCamera), defaultCamera, $"Only {CameraChoice.Front} & {CameraChoice.Rear} camera is supported."); } FindLargestResolution(); void Helper(LensFacing lensFacing) { foreach (string camId in Manager.GetCameraIdList()) { CameraCharacteristics cameraCharacteristics = Manager.GetCameraCharacteristics(camId); Integer facing = (Integer)cameraCharacteristics.Get(CameraCharacteristics.LensFacing); if (facing != null && facing == Integer.ValueOf((int)lensFacing)) { CameraCharacteristics = cameraCharacteristics; CameraId = camId; SensorOrientation = (int)CameraCharacteristics.Get(CameraCharacteristics.SensorOrientation); // Check if flash is supported Boolean flashAvailable = (Boolean)CameraCharacteristics.Get(CameraCharacteristics.FlashInfoAvailable); FlashSupported = flashAvailable != null && (bool)flashAvailable; } } } }
//public Boolean setHotspot(Boolean On) //{ // if (On) // { // // disable WiFi, this method i have works fine // setWifi(false); // try // { // Java.Lang.Boolean boolean = (Java.Lang.Boolean)On; // //WifiConfiguration wifiConfig = new WifiConfiguration(); // WifiConfiguration wifiConfig = (WifiConfiguration)GetSystemService(Context.WifiService); // wifiConfig.Ssid = device.Replace(" ", ""); //This is the network name based on which device run it (Office, eth) // var wifiManager = Application.Context.GetSystemService(Context.WifiService) as WifiManager; // var method = wifiManager.Class.GetMethod("setWifiApEnabled", wifiConfig.Class, boolean.Class); // return (Boolean)method.Invoke(wifiManager, wifiConfig, boolean); // } // catch (Exception e) // { // Log.Error(this.ToString(), e.Message); // return false; // } // } // return false; //} public void SetWifiTetheringEnabled(bool enable) { Java.Lang.Boolean boolean = (Java.Lang.Boolean)enable; WifiManager wifiManager = (WifiManager)_context.GetSystemService(Context.WifiService); WifiConfiguration wifiConfig = new WifiConfiguration(); if (enable) { wifiManager.SetWifiEnabled(false); } Method[] methods = wifiManager.Class.GetDeclaredMethods(); foreach (Method method in methods) { if (method.Name.Equals("setWifiApEnabled")) { Class[] parameterTypes = method.GetParameterTypes(); ITypeVariable[] typeParameters = method.GetTypeParameters(); method.Invoke(wifiManager, wifiConfig, boolean); break; } } }
public void OnSymbologyEnabled(ReaderDevice reader, ReaderDevice.Symbology symbology, Java.Lang.Boolean enabled, Throwable error) { if (Element != null) { Element.OnSymbologyEnabled(NativeToPortableSymbology(symbology), (bool)enabled, error?.LocalizedMessage); } }