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


Java EasyPermissions類代碼示例

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


EasyPermissions類屬於pub.devrel.easypermissions包,在下文中一共展示了EasyPermissions類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: requireAllPermissionForInit

import pub.devrel.easypermissions.EasyPermissions; //導入依賴的package包/類
@AfterPermissionGranted(WRITE_EXTERNAL_STORAGE)
private void requireAllPermissionForInit() {
    //可以隻獲取寫或者讀權限,同一個權限Group下隻要有一個權限申請通過了就都可以用了
    String[] perms = {Manifest.permission.WRITE_EXTERNAL_STORAGE};
    if (EasyPermissions.hasPermissions(this, perms)) {
        // Already have permission, do the thing
        if(!initReady){
            mainInit();
            initReady = true;
        }
        if(videoSniffer != null) {
            videoSniffer.startSniffer();
        }
        if (mainWebView != null) {
            mainWebView.resumeTimers();
            mainWebView.onShow();
        }
        startRefreshGoBackButtonStateThread();
    } else {
        // Do not have permissions, request them now
        EasyPermissions.requestPermissions(this, "下載需要讀寫外部存儲權限",
                WRITE_EXTERNAL_STORAGE, perms);
    }
}
 
開發者ID:xm0625,項目名稱:VBrowser-Android,代碼行數:25,代碼來源:MainActivity.java

示例2: chooseAccount

import pub.devrel.easypermissions.EasyPermissions; //導入依賴的package包/類
/**
 * Attempts to set the account used with the API credentials. If an account
 * name was previously saved it will use that one; otherwise an account
 * picker dialog will be shown to the user. Note that the setting the
 * account to use with the credentials object requires the app to have the
 * GET_ACCOUNTS permission, which is requested here if it is not already
 * present. The AfterPermissionGranted annotation indicates that this
 * function will be rerun automatically whenever the GET_ACCOUNTS permission
 * is granted.
 */
@AfterPermissionGranted(REQUEST_PERMISSION_GET_ACCOUNTS)
private void chooseAccount() {
    if (EasyPermissions.hasPermissions(
            this, Manifest.permission.GET_ACCOUNTS)) {
        String accountName = getPreferences(Context.MODE_PRIVATE)
                .getString(PREF_ACCOUNT_NAME, null);
        if (accountName != null) {
            mCredential.setSelectedAccountName(accountName);
            getResultsFromApi();
        } else {
            // Start a dialog from which the user can choose an account
            startActivityForResult(
                    mCredential.newChooseAccountIntent(),
                    REQUEST_ACCOUNT_PICKER);
        }
    } else {
        // Request the GET_ACCOUNTS permission via a user dialog
        EasyPermissions.requestPermissions(
                this,
                "This app needs to access your Google account (via Contacts).",
                REQUEST_PERMISSION_GET_ACCOUNTS,
                Manifest.permission.GET_ACCOUNTS);
    }
}
 
開發者ID:webianks,項目名稱:Crimson,代碼行數:35,代碼來源:CheckupReminders.java

示例3: requestWriteExternalStoragePermission

import pub.devrel.easypermissions.EasyPermissions; //導入依賴的package包/類
/**
 * Request runtime permissions method
 */
private void requestWriteExternalStoragePermission() {
    String[] permissions = {Manifest.permission.WRITE_EXTERNAL_STORAGE};
    if (EasyPermissions.hasPermissions(this, permissions)) {
        //Up next .... request Location
        requestLocationPermission();
    } else {
        // Do not have permissions, request permissions
        EasyPermissions.requestPermissions(MainActivity.this,
                getString(R.string.write_storage_request),
                R.string.allow_permission,
                R.string.deny_permission,
                WRITE_EXTERNAL_STORAGE_PERMISSION,
                permissions);
    }
}
 
開發者ID:CityZenApp,項目名稱:Android-Development,代碼行數:19,代碼來源:MainActivity.java

示例4: chooseAccount

import pub.devrel.easypermissions.EasyPermissions; //導入依賴的package包/類
/**
 * Attempts to set the account used with the API credentials. If an account
 * name was previously saved it will use that one; otherwise an account
 * picker dialog will be shown to the user. Note that the setting the
 * account to use with the credentials object requires the app to have the
 * GET_ACCOUNTS permission, which is requested here if it is not already
 * present. The AfterPermissionGranted annotation indicates that this
 * function will be rerun automatically whenever the GET_ACCOUNTS permission
 * is granted.
 */
@AfterPermissionGranted(REQUEST_PERMISSION_GET_ACCOUNTS)
private void chooseAccount() {
    if (EasyPermissions.hasPermissions(
            context, Manifest.permission.GET_ACCOUNTS)) {
        String accountName = context.getPreferences(Context.MODE_PRIVATE)
                .getString(PREF_ACCOUNT_NAME, null);
        if (accountName != null) {
            mCredential.setSelectedAccountName(accountName);
            getResultsFromApi();
        } else {
            // Start a dialog from which the user can choose an account
            context.startActivityForResult(
                    mCredential.newChooseAccountIntent(),
                    REQUEST_ACCOUNT_PICKER);
        }
    } else {
        // Request the GET_ACCOUNTS permission via a user dialog
        EasyPermissions.requestPermissions(
                context,
                "This app needs to access your Google account (via Contacts).",
                REQUEST_PERMISSION_GET_ACCOUNTS,
                Manifest.permission.GET_ACCOUNTS);
    }
}
 
開發者ID:Pl4gue,項目名稱:homeworkManager-android,代碼行數:35,代碼來源:GetHomeworkPresenter.java

示例5: chooseAccount

import pub.devrel.easypermissions.EasyPermissions; //導入依賴的package包/類
/**
 * Attempts to set the account used with the API credentials. If an account
 * name was previously saved it will use that one; otherwise an account
 * picker dialog will be shown to the user. Note that the setting the
 * account to use with the credentials object requires the app to have the
 * GET_ACCOUNTS permission, which is requested here if it is not already
 * present. The AfterPermissionGranted annotation indicates that this
 * function will be rerun automatically whenever the GET_ACCOUNTS permission
 * is granted.
 */
@AfterPermissionGranted(REQUEST_PERMISSION_GET_ACCOUNTS)
private void chooseAccount() {
    if (EasyPermissions.hasPermissions(
            context, Manifest.permission.GET_ACCOUNTS)) {
        String accountName = context.getPreferences(Context.MODE_PRIVATE)
                .getString(PREF_ACCOUNT_NAME, null);
        if (accountName != null) {
            mCredential.setSelectedAccountName(accountName);
            postHomeworkToApi(entryToAdd);
        } else {
            // Start a dialog from which the user can choose an account
            context.startActivityForResult(
                    mCredential.newChooseAccountIntent(),
                    REQUEST_ACCOUNT_PICKER);
        }
    } else {
        // Request the GET_ACCOUNTS permission via a user dialog
        EasyPermissions.requestPermissions(
                context,
                "This app needs to access your Google account (via Contacts).",
                REQUEST_PERMISSION_GET_ACCOUNTS,
                Manifest.permission.GET_ACCOUNTS);
    }
}
 
開發者ID:Pl4gue,項目名稱:homeworkManager-android,代碼行數:35,代碼來源:AddHomeworkPresenter.java

示例6: onRequestPermissionsResult

import pub.devrel.easypermissions.EasyPermissions; //導入依賴的package包/類
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {

    switch (requestCode){
        case 1:
            if (grantResults.length>0 && grantResults[0]==PackageManager.PERMISSION_GRANTED){
                openAlbum();
            }else {
                Toast.makeText(UIUtils.getContext(),"你關閉了權限功能",Toast.LENGTH_SHORT).show();
            }
            break;

        default:
            break;
    }

    super.onRequestPermissionsResult(requestCode, permissions, grantResults);

    // Forward results to EasyPermissions
    EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
}
 
開發者ID:android-jian,項目名稱:topnews,代碼行數:22,代碼來源:SettingFragment.java

示例7: requestPerm

import pub.devrel.easypermissions.EasyPermissions; //導入依賴的package包/類
/**
 * 申請權限的方法
 */

@AfterPermissionGranted(RC)
private void requestPerm() {
    String[] perms = new String[]{
            Manifest.permission.INTERNET,
            Manifest.permission.ACCESS_NETWORK_STATE,
            Manifest.permission.ACCESS_WIFI_STATE,
            Manifest.permission.RECORD_AUDIO,
            Manifest.permission.READ_EXTERNAL_STORAGE,
            Manifest.permission.WRITE_EXTERNAL_STORAGE
    };


    if (EasyPermissions.hasPermissions(getContext(), perms)) {
        App.showToast(R.string.label_permission_ok);
        // 判斷頁麵的跳轉
        getActivity().finish();
        LaunchActivity.showWitchAcitivty(getActivity());
    } else {
        EasyPermissions.requestPermissions(this,
                getString(R.string.title_assist_permissions),
                RC,
                perms);
    }
}
 
開發者ID:FZZFVII,項目名稱:pipe,代碼行數:29,代碼來源:PermisionsFragment.java

示例8: requestForStoragePermission

import pub.devrel.easypermissions.EasyPermissions; //導入依賴的package包/類
public void requestForStoragePermission() {
  final String[] permissions = new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE };
  if (EasyPermissions.hasPermissions(getActivity(), permissions)) {
    appDetailsPresenter.onPermissionGranted();
  } else {
    EasyPermissions.requestPermissions(this, getString(R.string.storage_permission_requirement),
        STORAGE_PERMISSION, permissions);
  }
}
 
開發者ID:Arjun-sna,項目名稱:android-permission-checker-app,代碼行數:10,代碼來源:AppDetailsFragment.java

示例9: getPermissions

import pub.devrel.easypermissions.EasyPermissions; //導入依賴的package包/類
@TargetApi(23)
private void getPermissions() {
  String[] permissions = new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE,
      Manifest.permission.RECORD_AUDIO};
  if (!EasyPermissions.hasPermissions(MainActivity.this, permissions)) {
    EasyPermissions.requestPermissions(this, getString(R.string.permissions_required),
        PERMISSION_REQ, permissions);
  }
}
 
開發者ID:Arjun-sna,項目名稱:Android-AudioRecorder-App,代碼行數:10,代碼來源:MainActivity.java

示例10: onPermissionsDenied

import pub.devrel.easypermissions.EasyPermissions; //導入依賴的package包/類
@Override
public void onPermissionsDenied(int requestCode, List<String> permissions) {
	if (EasyPermissions.somePermissionPermanentlyDenied(this, permissions)) {
		new AppSettingsDialog.Builder(this)
				.setRationale(R.string.rationale)
				.setTitle(R.string.title_rationale)
				.setPositiveButton(R.string.app_settings)
				.setNegativeButton(R.string.cancel)
				.setRequestCode(SETTINGS_REQUEST_CODE)
				.build()
				.show();
	}
}
 
開發者ID:EduardoVernier,項目名稱:bikedeboa-android,代碼行數:14,代碼來源:MapActivity.java

示例11: onRequestPermissionsResult

import pub.devrel.easypermissions.EasyPermissions; //導入依賴的package包/類
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);

    // Forward results to EasyPermissions
    EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
}
 
開發者ID:xm0625,項目名稱:VBrowser-Android,代碼行數:8,代碼來源:MainActivity.java

示例12: onRequestPermissionsResult

import pub.devrel.easypermissions.EasyPermissions; //導入依賴的package包/類
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);

    // Forward results to EasyPermissions
    EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
}
 
開發者ID:CodingCodersCode,項目名稱:EvolvingNetLib,代碼行數:8,代碼來源:DownloadListTestActivity.java

示例13: onPermissionsDenied

import pub.devrel.easypermissions.EasyPermissions; //導入依賴的package包/類
@Override
public void onPermissionsDenied(int requestCode, List<String> perms) {
    //Log.d(TAG, "onPermissionsDenied:" + requestCode + ":" + perms.size());

    // (Optional) Check whether the user denied any permissions and checked "NEVER ASK AGAIN."
    // This will display a dialog directing them to enable the permission in app settings.
    if (EasyPermissions.somePermissionPermanentlyDenied(this, perms)) {
        new AppSettingsDialog.Builder(this).build().show();
    }
}
 
開發者ID:CodingCodersCode,項目名稱:EvolvingNetLib,代碼行數:11,代碼來源:DownloadListTestActivity.java

示例14: requestPermissions

import pub.devrel.easypermissions.EasyPermissions; //導入依賴的package包/類
@Override
public void requestPermissions() {
    EasyPermissions.requestPermissions(this,
            getString(R.string.external_storage_permission_required),
            REQUEST_STORAGE_PERMISSION,
            Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
 
開發者ID:googlecodelabs,項目名稱:android-storage-permissions,代碼行數:8,代碼來源:ImagesFragment.java

示例15: onCreate

import pub.devrel.easypermissions.EasyPermissions; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    textView = findViewById(R.id.text);
    button = findViewById(R.id.button);
    imageView = findViewById(R.id.imageView);

    textView.setText(R.string.welcome_message);
    button.setText(R.string.button_text);
    imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);

    try {
        BufferedReader reader = new BufferedReader(new InputStreamReader(
                getAssets().open("synset_words.txt")
        ));
        while (true) {
            String line = reader.readLine();
            if (line == null) break;
            synsetWords.add(line);
        }

    } catch (IOException e) {
        e.printStackTrace();
    }

    if (EasyPermissions.hasPermissions(this, perms)) {
        initListener();

        ModelWrapper.readFile(getAssets(), "squeezenet.daq");
        ModelWrapper.setOutput("prob");
        ModelWrapper.compile(ModelWrapper.PREFERENCE_FAST_SINGLE_ANSWER);
    } else {
        // Do not have permissions, request them now
        EasyPermissions.requestPermissions(this, "Please grant",
                321, perms);
    }
}
 
開發者ID:daquexian,項目名稱:DNNLibrary,代碼行數:40,代碼來源:MainActivity.java


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