Camera2Basic.ErrorDialog.NewInstance C# (CSharp) Method

NewInstance() public static method

public static NewInstance ( string message ) : ErrorDialog
message string
return ErrorDialog
        public static ErrorDialog NewInstance(string message)
        {
            var args = new Bundle();
            args.PutString(ARG_MESSAGE, message);
            return new ErrorDialog { Arguments = args };
        }

Usage Example

Example #1
0
        // 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);
            }
        }
All Usage Examples Of Camera2Basic.ErrorDialog::NewInstance