当前位置: 首页>>代码示例>>Java>>正文


Java FragmentCompat.requestPermissions方法代码示例

本文整理汇总了Java中android.support.v13.app.FragmentCompat.requestPermissions方法的典型用法代码示例。如果您正苦于以下问题:Java FragmentCompat.requestPermissions方法的具体用法?Java FragmentCompat.requestPermissions怎么用?Java FragmentCompat.requestPermissions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v13.app.FragmentCompat的用法示例。


在下文中一共展示了FragmentCompat.requestPermissions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: requestCameraPermission

import android.support.v13.app.FragmentCompat; //导入方法依赖的package包/类
/**
 * Handles the requesting of the camera permission.  This includes
 * showing a "Snackbar" message of why the permission is needed then
 * sending the request.
 */
private void requestCameraPermission() {
    Log.w(TAG, "Camera permission is not granted. Requesting permission");

    final String[] permissions = new String[]{Manifest.permission.CAMERA};

    if (!FragmentCompat.shouldShowRequestPermissionRationale(this,
            Manifest.permission.CAMERA)) {
        FragmentCompat.requestPermissions(this, permissions, RC_HANDLE_CAMERA_PERM);
        return;
    }

    View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            FragmentCompat.requestPermissions(ScannerFragment.this, permissions,
                    RC_HANDLE_CAMERA_PERM);
        }
    };

    Snackbar.make(getView(), R.string.scanner_permission_camera_rationale,
            Snackbar.LENGTH_INDEFINITE)
            .setAction(android.R.string.ok, listener)
            .show();
}
 
开发者ID:MobileTribe,项目名称:pandroid,代码行数:30,代码来源:ScannerFragment.java

示例2: ask

import android.support.v13.app.FragmentCompat; //导入方法依赖的package包/类
private void ask(android.app.Activity activity, android.support.v4.app.Fragment v4fragment, android.app.Fragment fragment) {
    initArray();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        String[] permissionToAsk = permissionToAsk(activity, v4fragment, fragment);
        if (permissionToAsk.length == 0) {
            showResult();
        } else {
            if (activity != null) {
                ActivityCompat.requestPermissions(activity, permissionToAsk, key);
            } else if (fragment != null) {
                FragmentCompat.requestPermissions(fragment, permissionToAsk, key);
            } else if (v4fragment != null) {
                v4fragment.requestPermissions(permissionToAsk, key);
            }
        }
    } else {
        permissionsGranted.addAll(permissions);
        showResult();
    }
}
 
开发者ID:rebus007,项目名称:PermissionUtils,代码行数:21,代码来源:PermissionManager.java

示例3: requestCameraPermission

import android.support.v13.app.FragmentCompat; //导入方法依赖的package包/类
private void requestCameraPermission() {
    if (FragmentCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) {
        new ConfirmationDialog().show(getChildFragmentManager(), FRAGMENT_DIALOG);
    } else {
        FragmentCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA},
                REQUEST_CAMERA_PERMISSION);
    }
}
 
开发者ID:vulovicv23,项目名称:opencv-documentscanner-android,代码行数:9,代码来源:Camera2BasicFragment.java

示例4: requestVideoPermissions

import android.support.v13.app.FragmentCompat; //导入方法依赖的package包/类
/**
 * Requests permissions needed for recording video.
 */
private void requestVideoPermissions() {
    if (shouldShowRequestPermissionRationale(VIDEO_PERMISSIONS)) {
        new ConfirmationDialog().show(getChildFragmentManager(), FRAGMENT_DIALOG);
    } else {
        FragmentCompat.requestPermissions(this, VIDEO_PERMISSIONS, REQUEST_VIDEO_PERMISSIONS);
    }
}
 
开发者ID:garrylea,项目名称:Android-Camera2Video,代码行数:11,代码来源:Camera2VideoFragment.java

示例5: requestPermissions

import android.support.v13.app.FragmentCompat; //导入方法依赖的package包/类
private void requestPermissions() {
    if (shouldShowRequestPermissionRationale(REQUEST_PERMISSIONS)) {
        new ConfirmationDialog().show(getChildFragmentManager(), FRAGMENT_DIALOG);
    } else {
        FragmentCompat.requestPermissions(this, REQUEST_PERMISSIONS, REQUEST_CAMERA_PERMISSION);
    }
}
 
开发者ID:wingskyer,项目名称:android-Camera2Basic-master,代码行数:8,代码来源:Camera2BasicFragment.java

示例6: requestCameraPermission

import android.support.v13.app.FragmentCompat; //导入方法依赖的package包/类
public void requestCameraPermission() {
    if (FragmentCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) {
        showInfoDialog(R.string.ocr_camera_permission_explanation);
    } else {
        FragmentCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA},
                REQUEST_CAMERA_PERMISSION);
    }
}
 
开发者ID:digital-voting-pass,项目名称:polling-station-app,代码行数:9,代码来源:CameraFragment.java

示例7: requestStoragePermissions

import android.support.v13.app.FragmentCompat; //导入方法依赖的package包/类
private void requestStoragePermissions() {
    if (FragmentCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
        showInfoDialog(R.string.storage_permission_explanation);
    } else {
        FragmentCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_WRITE_PERMISSIONS);
    }
}
 
开发者ID:digital-voting-pass,项目名称:polling-station-app,代码行数:8,代码来源:CameraFragment.java

示例8: requestCameraPermissions

import android.support.v13.app.FragmentCompat; //导入方法依赖的package包/类
/**
 * Requests permissions necessary to use camera and save pictures.
 */
private void requestCameraPermissions() {
    if (shouldShowRationale()) {
        PermissionConfirmationDialog.newInstance().show(getChildFragmentManager(), "dialog");
    } else {
        FragmentCompat.requestPermissions(this, CAMERA_PERMISSIONS, REQUEST_CAMERA_PERMISSIONS);
    }
}
 
开发者ID:gengqifu,项目名称:361Camera,代码行数:11,代码来源:Camera2Fragment.java

示例9: requestCameraPermission

import android.support.v13.app.FragmentCompat; //导入方法依赖的package包/类
@Override
public void requestCameraPermission() {

    if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
        // Camera permission is already granted.
        // Threw Play Store installation before Android 6.0 or threw user approval during a previous app usage.
        presenter.onCameraPermissionGranted();
        return;
    }

    // Camera permission is not yet granted, request it now.
    // Because it should be obvious for a facial recognition app to require camera access "shouldShowRequestPermissionRationale()"
    // is not queried.
    FragmentCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, REQUEST_CODE_CAMERA_PERMISSION);
}
 
开发者ID:BioID-GmbH,项目名称:BWS-Android,代码行数:16,代码来源:FacialRecognitionFragment.java

示例10: requestCameraPermissions

import android.support.v13.app.FragmentCompat; //导入方法依赖的package包/类
/**
 * Requests permissions necessary to use camera and save pictures.
 */
private void requestCameraPermissions() {
    if (PermissionManager.shouldShowRationale(this)) {
        PermissionConfirmationDialog.newInstance().show(getChildFragmentManager(), "dialog");
    } else {
        FragmentCompat.requestPermissions(this, CAMERA_PERMISSIONS, REQUEST_CAMERA_PERMISSIONS);
    }
}
 
开发者ID:OkayCamera,项目名称:OkayCamera-Android,代码行数:11,代码来源:Camera2RawFragment.java

示例11: requestCameraPermission

import android.support.v13.app.FragmentCompat; //导入方法依赖的package包/类
private void requestCameraPermission() {
    if (shouldShowRequestPermissionRationale(VIDEO_PERMISSIONS)) {
        new ConfirmationDialog().show(getChildFragmentManager(), FRAGMENT_DIALOG);
    } else {
        FragmentCompat.requestPermissions(this, VIDEO_PERMISSIONS, REQUEST_CAMERA_PERMISSION);
    }
}
 
开发者ID:lytcom,项目名称:CameraKitView,代码行数:8,代码来源:Camera2Fragment.java

示例12: requestVideoPermissions

import android.support.v13.app.FragmentCompat; //导入方法依赖的package包/类
protected void requestVideoPermissions() {
    if (CameraUtil.shouldShowRequestPermissionRationale(this, Camera2PermissionDialog.VIDEO_PERMISSIONS)) {
        Camera2PermissionDialog.newInstance(this, mRationaleMessage).show(getChildFragmentManager(), Camera2PermissionDialog.FRAGMENT_DIALOG);
    } else {
        FragmentCompat.requestPermissions(this, Camera2PermissionDialog.VIDEO_PERMISSIONS, Camera2PermissionDialog.REQUEST_VIDEO_PERMISSIONS);
    }
}
 
开发者ID:WesleyElliott,项目名称:Camera2-Video,代码行数:8,代码来源:Camera2Fragment.java

示例13: requestCameraPermission

import android.support.v13.app.FragmentCompat; //导入方法依赖的package包/类
private void requestCameraPermission()
{
    if(FragmentCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA))
    {
        new ConfirmationDialog().show(getChildFragmentManager(), FRAGMENT_DIALOG);
    }
    else
    {
        FragmentCompat.requestPermissions(this,
                new String[] {Manifest.permission.CAMERA},
                REQUEST_CAMERA_PERMISSION);
    }
}
 
开发者ID:ResearchStack,项目名称:MoleMapperAndroid,代码行数:14,代码来源:LollipopCameraFragment.java

示例14: refreshCalendars

import android.support.v13.app.FragmentCompat; //导入方法依赖的package包/类
public void refreshCalendars(boolean forceRefresh) {

        Activity activity = getActivity();
        if(activity == null) {
            return;
        }

        if (ContextCompat.checkSelfPermission(activity, Manifest.permission.READ_CALENDAR) != PackageManager.PERMISSION_GRANTED) {
            // Not showing explanations, this should be very obvious
            FragmentCompat.requestPermissions(this, new String[]{Manifest.permission.READ_CALENDAR}, CALENDAR_PERMISSION_REQUEST);
        }
        else {
            refreshCalendarsWithPermission(forceRefresh);
        }
	}
 
开发者ID:RemiNV,项目名称:CalendarMute,代码行数:16,代码来源:CalendarsFragment.java

示例15: checkHasReadStoragePermission

import android.support.v13.app.FragmentCompat; //导入方法依赖的package包/类
private boolean checkHasReadStoragePermission() {
    if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        Log.d(TAG, "permission not granted yet, show dialog");
        FragmentCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, REQUEST_CODE_PERMISSION);
        return false;
    }
    Log.d(TAG, "permission already granted");
    return true;
}
 
开发者ID:patrickfav,项目名称:BlurTestAndroid,代码行数:10,代码来源:BlurBenchmarkFragment.java


注:本文中的android.support.v13.app.FragmentCompat.requestPermissions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。