Beispiel #1
0
 public void OnClick(IDialogInterface dialog, int which)
 {
     FragmentCompat.RequestPermissions(
         mParent,
         new string[] { Manifest.Permission.Camera },
         CameraConstants.REQUEST_CAMERA_PERMISSION
         );
 }
 private void RequestCameraPermission()
 {
     if (FragmentCompat.ShouldShowRequestPermissionRationale(this, Manifest.Permission.Camera))
     {
         new ConfirmationDialog().Show(ChildFragmentManager, CameraConstants.FRAGMENT_DIALOG);
     }
     else
     {
         FragmentCompat.RequestPermissions(this, new string[] { Manifest.Permission.Camera }, CameraConstants.REQUEST_CAMERA_PERMISSION);
     }
 }
Beispiel #3
0
        public static void PickFromGallery(Activity activity = null, FragmentCompat fragment = null)
        {
            // Filesystem.
            Intent galleryIntent = new Intent();

            galleryIntent.SetType("image/*");
            galleryIntent.SetAction(Intent.ActionGetContent);

            // Chooser of filesystem options.
            Intent chooserIntent = Intent.CreateChooser(galleryIntent, "Select Source");

            if (activity != null)
            {
                activity.StartActivityForResult(chooserIntent, INTENT_PICK_IMAGE);
            }
            if (fragment != null)
            {
                fragment.StartActivityForResult(chooserIntent, INTENT_PICK_IMAGE);
            }
        }
Beispiel #4
0
        private static void MultiSourceDialog(Activity activity, FragmentCompat fragment = null)
        {
            List <Intent>       cameraIntents  = new List <Intent>();
            Intent              captureIntent  = new Intent(MediaStore.ActionImageCapture);
            PackageManager      packageManager = activity.PackageManager;
            IList <ResolveInfo> listCam        = packageManager.QueryIntentActivities(captureIntent, 0);

            foreach (ResolveInfo res in listCam)
            {
                String packageName = res.ActivityInfo.PackageName;
                Intent intent      = new Intent(captureIntent);
                intent.SetComponent(new ComponentName(res.ActivityInfo.PackageName, res.ActivityInfo.Name));
                intent.SetPackage(packageName);
                TempFile = DroidUtil.GetChadderTempFile();
                intent.PutExtra(MediaStore.ExtraOutput, Android.Net.Uri.FromFile(new Java.IO.File(TempFile)));
                cameraIntents.Add(intent);
            }

            // Filesystem.
            Intent galleryIntent = new Intent();

            galleryIntent.SetType("image/*");
            galleryIntent.SetAction(Intent.ActionGetContent);

            // Chooser of filesystem options.
            Intent chooserIntent = Intent.CreateChooser(galleryIntent, "Select Source");

            // Add the camera options.
            chooserIntent.PutExtra(Intent.ExtraInitialIntents, cameraIntents.ToArray <IParcelable>());

            if (fragment == null)
            {
                activity.StartActivityForResult(chooserIntent, INTENT_PICK_IMAGE);
            }
            else
            {
                fragment.StartActivityForResult(chooserIntent, INTENT_PICK_IMAGE);
            }
        }
Beispiel #5
0
 public static void MultiSourcePick(FragmentCompat fragment)
 {
     MultiSourceDialog(fragment.Activity, fragment);
 }