當前位置: 首頁>>代碼示例>>Java>>正文


Java FragmentCompat類代碼示例

本文整理匯總了Java中android.support.v13.app.FragmentCompat的典型用法代碼示例。如果您正苦於以下問題:Java FragmentCompat類的具體用法?Java FragmentCompat怎麽用?Java FragmentCompat使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FragmentCompat類屬於android.support.v13.app包,在下文中一共展示了FragmentCompat類的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: onCreateDialog

import android.support.v13.app.FragmentCompat; //導入依賴的package包/類
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
    final Fragment parent = getParentFragment();
    return new AlertDialog.Builder(getActivity()).setMessage(R.string.request_permission)
            .setPositiveButton(android.R.string.ok, (dialog, which) -> {
                FragmentCompat.requestPermissions(parent,
                        new String[] {Manifest.permission.CAMERA},
                        REQUEST_CAMERA_PERMISSION);
            })
            .setNegativeButton(android.R.string.cancel, (dialog, which) -> {
                Activity activity = parent.getActivity();
                if(activity != null)
                {
                    activity.finish();
                }
            })
            .create();
}
 
開發者ID:ResearchStack,項目名稱:MoleMapperAndroid,代碼行數:20,代碼來源:LollipopCameraFragment.java

示例4: onRequestPermissionsResult

import android.support.v13.app.FragmentCompat; //導入依賴的package包/類
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    Log.d(TAG, "onRequestPermissionsResult " + requestCode);
    if (requestCode == REQUEST_CODE_PERMISSION) {
        if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            Log.d(TAG, "permission granted");
            startSelectImage();
        } else {
            if (FragmentCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_EXTERNAL_STORAGE)) {
                Log.d(TAG, "show permission rationale");
                Snackbar.make(getView(), "You need to allow the app to read your disk if you want to add custom images.", Snackbar.LENGTH_LONG).show();
            }
        }
    }
    Log.d(TAG, "permission denied");
}
 
開發者ID:patrickfav,項目名稱:BlurTestAndroid,代碼行數:18,代碼來源:BlurBenchmarkFragment.java

示例5: 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

示例6: shouldShowRequestPermissionRationale

import android.support.v13.app.FragmentCompat; //導入依賴的package包/類
/**
 * Gets whether you should show UI with rationale for requesting permissions.
 *
 * @param permissions The permissions your app wants to request.
 * @return Whether you can show permission rationale UI.
 */
private boolean shouldShowRequestPermissionRationale(String[] permissions) {
    for (String permission : permissions) {
        if (FragmentCompat.shouldShowRequestPermissionRationale(this, permission)) {
            return true;
        }
    }
    return false;
}
 
開發者ID:mywitness,項目名稱:Camara2-Video-Demo-fixed,代碼行數:15,代碼來源:Camera2VideoFragment.java

示例7: 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

示例8: shouldShowRequestPermissionRationale

import android.support.v13.app.FragmentCompat; //導入依賴的package包/類
private boolean shouldShowRequestPermissionRationale(String[] permissions) {
    for (String permission : permissions) {
        if (FragmentCompat.shouldShowRequestPermissionRationale(this, permission)) {
            return true;
        }
    }
    return false;
}
 
開發者ID:wingskyer,項目名稱:android-Camera2Basic-master,代碼行數:9,代碼來源:Camera2BasicFragment.java

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: shouldShowRationale

import android.support.v13.app.FragmentCompat; //導入依賴的package包/類
/**
 * Gets whether you should show UI with rationale for requesting the permissions.
 *
 * @return True if the UI should be shown.
 */
private boolean shouldShowRationale() {
    for (String permission : CAMERA_PERMISSIONS) {
        if (FragmentCompat.shouldShowRequestPermissionRationale(this, permission)) {
            return true;
        }
    }
    return false;
}
 
開發者ID:gengqifu,項目名稱:361Camera,代碼行數:14,代碼來源:Camera2Fragment.java

示例14: 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

示例15: shouldShowRationale

import android.support.v13.app.FragmentCompat; //導入依賴的package包/類
/**
 * Gets whether you should show UI with rationale for requesting the permissions.
 *
 * @return True if the UI should be shown.
 */
public static boolean  shouldShowRationale(Fragment fragment) {
    for (String permission : CAMERA_PERMISSIONS) {
        if (FragmentCompat.shouldShowRequestPermissionRationale(fragment, permission)) {
            return true;
        }
    }
    return false;
}
 
開發者ID:OkayCamera,項目名稱:OkayCamera-Android,代碼行數:14,代碼來源:PermissionManager.java


注:本文中的android.support.v13.app.FragmentCompat類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。