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


Java AfterPermissionGranted类代码示例

本文整理汇总了Java中pub.devrel.easypermissions.AfterPermissionGranted的典型用法代码示例。如果您正苦于以下问题:Java AfterPermissionGranted类的具体用法?Java AfterPermissionGranted怎么用?Java AfterPermissionGranted使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: downloadFile

import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的package包/类
@AfterPermissionGranted(WRITE_EXTERNAL_REQUEST_CODE)
public void downloadFile(String url, String userAgent, String contentDisposition, String mimetype) {
    DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
    request.setMimeType(mimetype);
    cookieManager = CookieManager.getInstance();
    PersistentConfig persistentConfig = new PersistentConfig(activity.getApplicationContext());
    persistentConfig.setCookie(getCookies(Session.getSession(activity.getApplicationContext())));
    cookieManager.setCookie(host, persistentConfig.getCookieString());
    request.addRequestHeader("Cookie", getCookies(Session.getSession(activity.getApplicationContext())));
    request.setDescription("Downloading file...");
    request.setTitle(URLUtil.guessFileName(url, contentDisposition, mimetype));
    request.allowScanningByMediaScanner();
    request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
    String fileName = URLUtil.guessFileName(url, contentDisposition, mimetype);
    request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);
    DownloadManager dManager = (DownloadManager) getActivity().getSystemService(DOWNLOAD_SERVICE);
    dManager.enqueue(request);
}
 
开发者ID:active-citizen,项目名称:android.java,代码行数:19,代码来源:WebShopFragment.java

示例2: createLayers

import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的package包/类
@AfterPermissionGranted(PERMISSIONS_REQUEST_READ_STORAGE)
private void createLayers() {
    if (EasyPermissions.hasPermissions(getContext(), Manifest.permission.READ_EXTERNAL_STORAGE)) {
        TileCache tileCache = AndroidUtil.createTileCache(getContext(),
                "mapFragment",
                this.mapView.getModel().displayModel.getTileSize(),
                1.0f,
                this.mapView.getModel().frameBufferModel.getOverdrawFactor());

        final Layers layers = this.mapView.getLayerManager().getLayers();
        final MapViewPosition mapViewPosition = this.mapView.getModel().mapViewPosition;

        initializePosition(mapViewPosition);

        TileRendererLayer tileRendererLayer = createTileRendererLayer(tileCache, mapViewPosition,
                getMapFile(), getRenderTheme());
        layers.add(tileRendererLayer);

        LabelLayer labelLayer = new LabelLayer(AndroidGraphicFactory.INSTANCE, tileRendererLayer.getLabelStore());
        mapView.getLayerManager().getLayers().add(labelLayer);

        // overlay with a marker to show the goal position
        this.goalLocationOverlay = new Marker(null, null, 0, 0);
        layers.add(this.goalLocationOverlay);

        createLocationLayer();
    } else {
        EasyPermissions.requestPermissions(
                this,
                "",
                PERMISSIONS_REQUEST_READ_STORAGE,
                Manifest.permission.READ_EXTERNAL_STORAGE);
    }
}
 
开发者ID:marunjar,项目名称:anewjkuapp,代码行数:35,代码来源:MapFragment.java

示例3: requireSomePermission

import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的package包/类
@AfterPermissionGranted(num)
private void requireSomePermission() {
    String[] perms = {
            Manifest.permission.ACCESS_COARSE_LOCATION,
            Manifest.permission.WRITE_EXTERNAL_STORAGE,
            Manifest.permission.READ_PHONE_STATE,
            Manifest.permission.WRITE_SETTINGS
    };
    if (EasyPermissions.hasPermissions(this, perms)) {
        // Already have permission, do the thing
        Log.i("requireSomePermission", "Permissions Granted!");
    } else {
        // Do not have permissions, request them now
        EasyPermissions.requestPermissions(this, "",
                num, perms);
    }
}
 
开发者ID:GrayXu,项目名称:HustEating,代码行数:18,代码来源:MainActivity.java

示例4: requireAllPermissionForInit

import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的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

示例5: chooseAccount

import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的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

示例6: chooseAccount

import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的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

示例7: requestPerm

import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的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: chooseAccount

import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的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

示例9: chooseAccount

import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的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)
void chooseAccount() {
    if (EasyPermissions.hasPermissions(this, Manifest.permission.GET_ACCOUNTS)) {
        String accountName = mSettingsManager.getString(SettingsConstants.PREF_ACCOUNT_NAME);
        if (accountName != null && !accountName.isEmpty()) {
            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,
                getString(R.string.msg_needs_google_account),
                REQUEST_PERMISSION_GET_ACCOUNTS,
                Manifest.permission.GET_ACCOUNTS);
    }
}
 
开发者ID:ITVlab,项目名称:Family-Calendar,代码行数:33,代码来源:MainLeanbackActivity.java

示例10: chooseAccount

import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的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)
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:ITVlab,项目名称:Family-Calendar,代码行数:35,代码来源:QuickStartActivity.java

示例11: onResume

import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的package包/类
@AfterPermissionGranted(LOCATION_MICROPHONE_PERM)
@Override
public void onResume() {
    super.onResume();

    String[] perms = {Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.RECORD_AUDIO};
    if (EasyPermissions.hasPermissions(getContext(), perms)) {
        mPresenter.startRecord(getContext());
        mapView.onResume();
    } else {
        // Do not have permissions, request them now
        EasyPermissions.requestPermissions(this, "",
                LOCATION_MICROPHONE_PERM, perms);
    }


}
 
开发者ID:Alex-ZHOU,项目名称:VMAndroid,代码行数:18,代码来源:RecordFragment.java

示例12: getPerm

import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的package包/类
@AfterPermissionGranted(RC_EXTERNAL_STORAGE_PHONE_STATE_PER)
private void getPerm() {
    if (!EasyPermissions.hasPermissions(this, Constants.EXTERNAL_STORAGE_PHONE_STATE_PER)) {
        // Ask for one permission
        EasyPermissions.requestPermissions(this,
                                           getString(R.string.rationale_camera),
                                           RC_EXTERNAL_STORAGE_PHONE_STATE_PER,
                                           Constants.EXTERNAL_STORAGE_PHONE_STATE_PER);
    }
    AdManager.getInstance(this)
             .init(Constants.APPID, Constants.APPSECRET, false, true);
    mBtnStartService = (Button) findViewById(R.id.maina_start_service);
    mBtnUpdate = (Button) findViewById(R.id.maina_update);
    mBtnShare = (Button) findViewById(R.id.maina_share);
    mBtnStartService.setOnClickListener(this);
    mBtnUpdate.setOnClickListener(this);
    mBtnShare.setOnClickListener(this);
}
 
开发者ID:ynztlxdeai,项目名称:MoneyPackage,代码行数:19,代码来源:MainActivity.java

示例13: onAudioClick

import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的package包/类
@AfterPermissionGranted(RECORD_AUDIO)
private void onAudioClick() {
    // Check that we have permission to read images from external storage.
    grantStoragePermission();
    
    if (!EasyPermissions.hasPermissions(mActivity, Manifest.permission.RECORD_AUDIO)) {
        EasyPermissions.requestPermissions(mActivity, "If you want to do this continue, " +
                "you should give App record audio permission ", RECORD_AUDIO, Manifest.permission.RECORD_AUDIO);
    }
    
    // Choose file storage location, must be listed in res/xml/file_paths.xml
    File dir = new File(Environment.getExternalStorageDirectory() + "/MoonlightNote/.audio");
    
    if (!dir.exists()) {
        boolean isDirCreate = dir.mkdirs();
        if (BuildConfig.DEBUG) { Log.d(TAG, "onAudioClick: " + isDirCreate); }
    }
    displaySpeechRecognizer();
}
 
开发者ID:Art2Cat,项目名称:MoonlightNote,代码行数:20,代码来源:MoonlightDetailFragment.java

示例14: requestPermission

import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的package包/类
@AfterPermissionGranted(STORAGE_PERMS)
private void requestPermission(int type) {
    if (!EasyPermissions.hasPermissions(getActivity(),
            Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
        EasyPermissions.requestPermissions(getActivity(),
                "If you want to do this continue, " +
                        "you should give App storage permission ",
                STORAGE_PERMS, Manifest.permission.WRITE_EXTERNAL_STORAGE);
    } else {
        if (type == 0) {
            mFDatabaseUtils.exportNote(0);
        } else {
            mFDatabaseUtils.restoreAll();
        }
    }
}
 
开发者ID:Art2Cat,项目名称:MoonlightNote,代码行数:17,代码来源:SettingsActivity.java

示例15: findFriends

import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的package包/类
@AfterPermissionGranted(CONTACTS_PERMISSION_REQUEST_CODE)
private void findFriends() {
    if (ContactsController.Manager.isNeedUpdate(this)) {
        if (EasyPermissions.hasPermissions(this, CONTACTS_PERMS)) {
            ContactsController contactsController = new ContactsController(this);
            contactsController.setPhone(AgUser.getPhone(this));
            contactsController.silentFindFriends();
            ContactsController.Manager.increment(this);
        } else {
            EasyPermissions.requestPermissions(this,
                    getString(R.string.permission_contacts),
                    CONTACTS_PERMISSION_REQUEST_CODE,
                    CONTACTS_PERMS);
        }
    }
}
 
开发者ID:active-citizen,项目名称:android.java,代码行数:17,代码来源:MainActivity.java


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