pub.devrel.easypermissions.AfterPermissionGranted Java Examples

The following examples show how to use pub.devrel.easypermissions.AfterPermissionGranted. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java    From opentok-android-sdk-samples with MIT License 6 votes vote down vote up
@AfterPermissionGranted(RC_VIDEO_APP_PERM)
private void requestPermissions() {
    String[] perms = { Manifest.permission.INTERNET, Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO };
    if (EasyPermissions.hasPermissions(this, perms)) {
        // initialize view objects from your layout
        mPublisherViewContainer = (FrameLayout) findViewById(R.id.publisher_container);
        mSubscriberViewContainer = (FrameLayout) findViewById(R.id.subscriber_container);
        mArchivingIndicatorView = (ImageView) findViewById(R.id.archiving_indicator_view);

        // initialize WebServiceCoordinator and kick off request for session data
        // session initialization occurs once data is returned, in onSessionConnectionDataReady
        mWebServiceCoordinator = new WebServiceCoordinator(this, this);
        mWebServiceCoordinator.fetchSessionConnectionData(OpenTokConfig.SESSION_INFO_ENDPOINT);
    } else {
        EasyPermissions.requestPermissions(this, getString(R.string.rationale_video_app), RC_VIDEO_APP_PERM, perms);
    }
}
 
Example #2
Source File: StartUI.java    From Pix-Art-Messenger with GNU General Public License v3.0 6 votes vote down vote up
@AfterPermissionGranted(NeededPermissions)
private void requestNeededPermissions() {
    String PREF_FIRST_START = "FirstStart";
    SharedPreferences FirstStart = getApplicationContext().getSharedPreferences(PREF_FIRST_START, Context.MODE_PRIVATE);
    long FirstStartTime = FirstStart.getLong(PREF_FIRST_START, 0);
    if (EasyPermissions.hasPermissions(this, perms)) {
        // Already have permission, start ConversationsActivity
        Log.d(Config.LOGTAG, "All permissions granted, starting " + getString(R.string.app_name) + "(" + FirstStartTime + ")");
        Intent intent = new Intent(this, ConversationsActivity.class);
        intent.putExtra(PREF_FIRST_START, FirstStartTime);
        startActivity(intent);
        overridePendingTransition(R.animator.fade_in, R.animator.fade_out);
        finish();
    } else {
        // set first start to 0 if there are permissions to request
        Log.d(Config.LOGTAG, "Requesting required permissions");
        SharedPreferences.Editor editor = FirstStart.edit();
        editor.putLong(PREF_FIRST_START, 0);
        editor.commit();
        // Do not have permissions, request them now
        EasyPermissions.requestPermissions(this, getString(R.string.request_permissions_message),
                NeededPermissions, perms);
    }
}
 
Example #3
Source File: WiFiActivity.java    From android_connectionbuddy with Apache License 2.0 6 votes vote down vote up
@AfterPermissionGranted(RC_LOCATION)
private void connectToWifi() {
    String[] perms = {Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION};
    if (EasyPermissions.hasPermissions(this, perms)) {
        try {
            ConnectionBuddy.getInstance()
                    .connectToWifiConfiguration(this, etSsid.getText().toString(), etPassword.getText().toString(), true,
                            WiFiActivity.this);
        } catch (SecurityException e) {
            e.printStackTrace();
        }
    } else {
        // Do not have permissions, request them now
        EasyPermissions.requestPermissions(this, getString(R.string.change_wifi_state_rationale),
                RC_LOCATION, perms);
    }
}
 
Example #4
Source File: MainActivity.java    From apps-script-mobile-addons with Apache License 2.0 6 votes vote down vote up
/**
 * Attempts to initialize credentials and service object (prior to a call
 * to the API); uses the account provided by the calling app. This
 * requires the GET_ACCOUNTS permission to be explicitly granted by the
 * user; this will be requested here if it is not already granted. 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 createCredentialsAndService() {
    if (EasyPermissions.hasPermissions(
            MainActivity.this, Manifest.permission.GET_ACCOUNTS)) {
        mCredential = GoogleAccountCredential.usingOAuth2(
                getApplicationContext(), Arrays.asList(SCOPES))
                .setBackOff(new ExponentialBackOff())
                .setSelectedAccountName(mAccount.name);
        mService = new com.google.api.services.script.Script.Builder(
                mTransport, mJsonFactory, setHttpTimeout(mCredential))
                .setApplicationName(getString(R.string.app_name))
                .build();
        updateButtonEnableStatus();

        // Callback to retry the API call with valid service/credentials
        callAppsScriptTask(mLastFunctionCalled);
    } else {
        // Request the GET_ACCOUNTS permission via a user dialog
        EasyPermissions.requestPermissions(
                MainActivity.this,
                getString(R.string.get_accounts_rationale),
                REQUEST_PERMISSION_GET_ACCOUNTS,
                Manifest.permission.GET_ACCOUNTS);
    }
}
 
Example #5
Source File: MainActivity.java    From opentok-android-sdk-samples with MIT License 6 votes vote down vote up
@AfterPermissionGranted(RC_VIDEO_APP_PERM)
private void requestPermissions() {
    String[] perms = {
            Manifest.permission.INTERNET,
            Manifest.permission.CAMERA,
            Manifest.permission.RECORD_AUDIO,
            Manifest.permission.WRITE_EXTERNAL_STORAGE
    };
    if (EasyPermissions.hasPermissions(this, perms)) {
        mSession = new Session.Builder(MainActivity.this, OpenTokConfig.API_KEY, OpenTokConfig.SESSION_ID).build();
        mSession.setSessionListener(this);
        mSession.connect(OpenTokConfig.TOKEN);
    } else {
        EasyPermissions.requestPermissions(this, getString(R.string.rationale_video_app), RC_VIDEO_APP_PERM, perms);
    }
}
 
Example #6
Source File: FeedAddActivity.java    From SmallGdufe-Android with GNU General Public License v3.0 6 votes vote down vote up
@AfterPermissionGranted(PRC_PHOTO_PICKER)
private void choicePhotoWrapper() {
    String[] perms = {Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA};
    if (EasyPermissions.hasPermissions(this, perms)) {
        // 拍照后照片的存放目录,改成你自己拍照后要存放照片的目录。如果不传递该参数的话就没有拍照功能
        File takePhotoDir = new File(Environment.getExternalStorageDirectory(), AppConfig.sdSaveDirName);

        Intent photoPickerIntent = new BGAPhotoPickerActivity.IntentBuilder(this)
                .cameraFileDir(takePhotoDir) // 拍照后照片的存放目录,改成你自己拍照后要存放照片的目录。如果不传递该参数的话则不开启图库里的拍照功能
                .maxChooseCount(mPhotosSnpl.getMaxItemCount() - mPhotosSnpl.getItemCount()) // 图片选择张数的最大值
                .selectedPhotos(null) // 当前已选中的图片路径集合
                .pauseOnScroll(false) // 滚动列表时是否暂停加载图片
                .build();
        startActivityForResult(photoPickerIntent, RC_CHOOSE_PHOTO);
    } else {
        EasyPermissions.requestPermissions(this, "图片选择需要以下权限:\n\n1.访问设备上的照片\n\n2.拍照", PRC_PHOTO_PICKER, perms);
    }
}
 
Example #7
Source File: CheckupReminders.java    From Crimson with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example #8
Source File: MainActivity.java    From opentok-android-sdk-samples with MIT License 6 votes vote down vote up
@AfterPermissionGranted(RC_VIDEO_APP_PERM)
private void requestPermissions() {
    String[] perms = {
            Manifest.permission.INTERNET,
            Manifest.permission.CAMERA,
            Manifest.permission.RECORD_AUDIO
    };
    if (EasyPermissions.hasPermissions(this, perms)) {
        mSession = new Session.Builder(this, OpenTokConfig.API_KEY, OpenTokConfig.SESSION_ID).sessionOptions(new Session.SessionOptions() {
            @Override
            public boolean useTextureViews() {
                return true;
            }
        }).build();
        mSession.setSessionListener(this);
        mSession.connect(OpenTokConfig.TOKEN);

        startPublisherPreview();
        mPublisher.getView().setId(R.id.publisher_view_id);
        mContainer.addView(mPublisher.getView());
        calculateLayout();
    } else {
        EasyPermissions.requestPermissions(this, getString(R.string.rationale_video_app), RC_VIDEO_APP_PERM, perms);
    }
}
 
Example #9
Source File: GuideActivity.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
@AfterPermissionGranted(RC_LOCATION_CONTACTS_PERM)
public void locationPermissionsTask() {
    //检查是否获取该权限
    if (hasPermissions()) {
        startCheckService();
        //具备权限 直接进行操作
        startLoading();
        //startCheckService();
    } else {
        //权限拒绝 申请权限
        //第二个参数是被拒绝后再次申请该权限的解释
        //第三个参数是请求码
        //第四个参数是要申请的权限
        EasyPermissions.requestPermissions(this,
                getString(R.string.easy_permissions), RC_LOCATION_CONTACTS_PERM, LOCATION_AND_CONTACTS);
    }
}
 
Example #10
Source File: MainActivity.java    From VBrowser-Android with GNU General Public License v2.0 6 votes vote down vote up
@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);
    }
}
 
Example #11
Source File: TraitEditorActivity.java    From Field-Book with GNU General Public License v2.0 6 votes vote down vote up
@AfterPermissionGranted(PERMISSIONS_REQUEST_STORAGE_IMPORT)
public void loadTraitFilePermission() {
    String[] perms = {Manifest.permission.READ_EXTERNAL_STORAGE};
    if (EasyPermissions.hasPermissions(this, perms)) {
        if (ep.getBoolean("TraitsExported", false)) {
            showFileDialog();
        } else {
            checkTraitExportDialog();
        }
    } else {
        // Do not have permissions, request them now
        EasyPermissions.requestPermissions(this, getString(R.string.permission_rationale_storage_import),
                PERMISSIONS_REQUEST_STORAGE_IMPORT, perms);
    }

}
 
Example #12
Source File: ConfigActivity.java    From Field-Book with GNU General Public License v2.0 5 votes vote down vote up
@AfterPermissionGranted(PERMISSIONS_REQUEST_TRAIT_DATA)
public void collectDataFilePermission() {
    String[] perms = {Manifest.permission.RECORD_AUDIO, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.CAMERA};
    if (EasyPermissions.hasPermissions(this, perms)) {
        Intent intent = new Intent();

        intent.setClassName(ConfigActivity.this,
                CollectActivity.class.getName());
        startActivity(intent);
    } else {
        // Do not have permissions, request them now
        EasyPermissions.requestPermissions(this, getString(R.string.permission_rationale_trait_features),
                PERMISSIONS_REQUEST_TRAIT_DATA, perms);
    }
}
 
Example #13
Source File: MainActivity.java    From easypermissions with Apache License 2.0 5 votes vote down vote up
@AfterPermissionGranted(RC_CAMERA_PERM)
public void cameraTask() {
    if (hasCameraPermission()) {
        // Have permission, do the thing!
        Toast.makeText(this, "TODO: Camera things", Toast.LENGTH_LONG).show();
    } else {
        // Ask for one permission
        EasyPermissions.requestPermissions(
                this,
                getString(R.string.rationale_camera),
                RC_CAMERA_PERM,
                Manifest.permission.CAMERA);
    }
}
 
Example #14
Source File: MainActivity.java    From easypermissions with Apache License 2.0 5 votes vote down vote up
@AfterPermissionGranted(RC_LOCATION_CONTACTS_PERM)
public void locationAndContactsTask() {
    if (hasLocationAndContactsPermissions()) {
        // Have permissions, do the thing!
        Toast.makeText(this, "TODO: Location and Contacts things", Toast.LENGTH_LONG).show();
    } else {
        // Ask for both permissions
        EasyPermissions.requestPermissions(
                this,
                getString(R.string.rationale_location_contacts),
                RC_LOCATION_CONTACTS_PERM,
                LOCATION_AND_CONTACTS);
    }
}
 
Example #15
Source File: QRCodeScannerActivity.java    From Upchain-wallet with GNU Affero General Public License v3.0 5 votes vote down vote up
@AfterPermissionGranted(REQUEST_CODE_QRCODE_PERMISSIONS)
private void requestCodeQRCodePermissions() {
    String[] perms = {Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE};
    if (!EasyPermissions.hasPermissions(this, perms)) {
        EasyPermissions.requestPermissions(this, "扫描二维码需要打开相机和散光灯的权限", REQUEST_CODE_QRCODE_PERMISSIONS, perms);
    }
}
 
Example #16
Source File: ImageActivity.java    From FirebaseUI-Android with Apache License 2.0 5 votes vote down vote up
@OnClick(R.id.button_choose_photo)
@AfterPermissionGranted(RC_IMAGE_PERMS)
protected void choosePhoto() {
    if (!EasyPermissions.hasPermissions(this, PERMS)) {
        EasyPermissions.requestPermissions(this, getString(R.string.rational_image_perm),
                                           RC_IMAGE_PERMS, PERMS);
        return;
    }

    Intent i = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    startActivityForResult(i, RC_CHOOSE_PHOTO);
}
 
Example #17
Source File: MainActivity.java    From opentok-android-sdk-samples with MIT License 5 votes vote down vote up
@AfterPermissionGranted(RC_VIDEO_APP_PERM)
private void requestPermissions() {
    String[] perms = { Manifest.permission.INTERNET, Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO };
    if (EasyPermissions.hasPermissions(this, perms)) {
        mSession = new Session.Builder(MainActivity.this, OpenTokConfig.API_KEY, OpenTokConfig.SESSION_ID).build();
        mSession.setSessionListener(this);
        mSession.connect(OpenTokConfig.TOKEN);
    } else {
        EasyPermissions.requestPermissions(this, getString(R.string.rationale_video_app), RC_VIDEO_APP_PERM, perms);
    }
}
 
Example #18
Source File: MainActivity.java    From opentok-android-sdk-samples with MIT License 5 votes vote down vote up
@AfterPermissionGranted(RC_VIDEO_APP_PERM)
private void requestPermissions() {
    String[] perms = {Manifest.permission.INTERNET, Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO};
    if (EasyPermissions.hasPermissions(this, perms)) {
        mSession = new Session.Builder(MainActivity.this, OpenTokConfig.API_KEY, OpenTokConfig.SESSION_ID).build();
        mSession.setSessionListener(this);
        mSession.connect(OpenTokConfig.TOKEN);
    } else {
        EasyPermissions.requestPermissions(this, getString(R.string.rationale_video_app), RC_VIDEO_APP_PERM, perms);
    }
}
 
Example #19
Source File: MainActivity.java    From opentok-android-sdk-samples with MIT License 5 votes vote down vote up
@AfterPermissionGranted(RC_VIDEO_APP_PERM)
private void requestPermissions() {
    String[] perms = {Manifest.permission.INTERNET, Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO};
    if (EasyPermissions.hasPermissions(this, perms)) {
        mSession = new Session.Builder(MainActivity.this, OpenTokConfig.API_KEY, OpenTokConfig.SESSION_ID).build();
        mSession.setSessionListener(this);
        mSession.connect(OpenTokConfig.TOKEN);
    } else {
        EasyPermissions.requestPermissions(this, getString(R.string.rationale_video_app), RC_VIDEO_APP_PERM, perms);
    }
}
 
Example #20
Source File: MainActivity.java    From opentok-android-sdk-samples with MIT License 5 votes vote down vote up
@AfterPermissionGranted(RC_VIDEO_APP_PERM)
private void requestPermissions() {
    String[] perms = {
            Manifest.permission.INTERNET,
            Manifest.permission.CAMERA,
            Manifest.permission.RECORD_AUDIO
    };
    if (EasyPermissions.hasPermissions(this, perms)) {
        mSession = new Session.Builder(MainActivity.this, OpenTokConfig.API_KEY, OpenTokConfig.SESSION_ID).build();
        mSession.setSessionListener(this);
        mSession.connect(OpenTokConfig.TOKEN);
    } else {
        EasyPermissions.requestPermissions(this, getString(R.string.rationale_video_app), RC_VIDEO_APP_PERM, perms);
    }
}
 
Example #21
Source File: ConfigActivity.java    From Field-Book with GNU General Public License v2.0 5 votes vote down vote up
@AfterPermissionGranted(PERMISSIONS_REQUEST_EXPORT_DATA)
private void exportPermission() {
    String[] perms = {Manifest.permission.READ_EXTERNAL_STORAGE};
    if (EasyPermissions.hasPermissions(this, perms)) {
        showSaveDialog();
    } else {
        EasyPermissions.requestPermissions(this, getString(R.string.permission_rationale_storage_export),
                PERMISSIONS_REQUEST_EXPORT_DATA, perms);
    }
}
 
Example #22
Source File: MainActivity.java    From opentok-android-sdk-samples with MIT License 5 votes vote down vote up
@AfterPermissionGranted(RC_VIDEO_APP_PERM)
private void requestPermissions() {

    String[] perms = { Manifest.permission.INTERNET, Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO };
    if (EasyPermissions.hasPermissions(this, perms)) {
        // if there is no server URL set
        if (OpenTokConfig.CHAT_SERVER_URL == null) {
            // use hard coded session values
            if (OpenTokConfig.areHardCodedConfigsValid()) {
                initializeSession(OpenTokConfig.API_KEY, OpenTokConfig.SESSION_ID, OpenTokConfig.TOKEN);
            } else {
                showConfigError("Configuration Error", OpenTokConfig.hardCodedConfigErrorMessage);
            }
        } else {
            // otherwise initialize WebServiceCoordinator and kick off request for session data
            // session initialization occurs once data is returned, in onSessionConnectionDataReady
            if (OpenTokConfig.isWebServerConfigUrlValid()) {
                mWebServiceCoordinator = new WebServiceCoordinator(this, this);
                mWebServiceCoordinator.fetchSessionConnectionData(OpenTokConfig.SESSION_INFO_ENDPOINT);
            } else {
                showConfigError("Configuration Error", OpenTokConfig.webServerConfigErrorMessage);
            }
        }
    } else {
        EasyPermissions.requestPermissions(this, getString(R.string.rationale_video_app), RC_VIDEO_APP_PERM, perms);
    }
}
 
Example #23
Source File: MainActivity.java    From opentok-android-sdk-samples with MIT License 5 votes vote down vote up
@AfterPermissionGranted(RC_VIDEO_APP_PERM)
private void requestPermissions() {
    String[] perms = { Manifest.permission.INTERNET, Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO };
    if (EasyPermissions.hasPermissions(this, perms)) {
        CustomAudioDevice customAudioDevice = new CustomAudioDevice(MainActivity.this);
        AudioDeviceManager.setAudioDevice(customAudioDevice);

        mSession = new Session.Builder(MainActivity.this, OpenTokConfig.API_KEY, OpenTokConfig.SESSION_ID).build();
        mSession.setSessionListener(this);
        mSession.connect(OpenTokConfig.TOKEN);
    } else {
        EasyPermissions.requestPermissions(this, getString(R.string.rationale_video_app), RC_VIDEO_APP_PERM, perms);
    }
}
 
Example #24
Source File: ConfigActivity.java    From Field-Book with GNU General Public License v2.0 5 votes vote down vote up
@AfterPermissionGranted(PERMISSIONS_REQUEST_DATABASE_EXPORT)
public void exportDatabaseFilePermission() {
    String[] perms = {Manifest.permission.READ_EXTERNAL_STORAGE};
    if (EasyPermissions.hasPermissions(this, perms)) {
        showDatabaseExportDialog();
    } else {
        // Do not have permissions, request them now
        EasyPermissions.requestPermissions(this, getString(R.string.permission_rationale_storage_export),
                PERMISSIONS_REQUEST_DATABASE_EXPORT, perms);
    }
}
 
Example #25
Source File: TraitEditorActivity.java    From Field-Book with GNU General Public License v2.0 5 votes vote down vote up
@AfterPermissionGranted(PERMISSIONS_REQUEST_STORAGE_EXPORT)
public void exportTraitFilePermission() {
    String[] perms = {Manifest.permission.READ_EXTERNAL_STORAGE};
    if (EasyPermissions.hasPermissions(this, perms)) {
        showExportDialog();
    } else {
        // Do not have permissions, request them now
        EasyPermissions.requestPermissions(this, getString(R.string.permission_rationale_storage_export),
                PERMISSIONS_REQUEST_STORAGE_EXPORT, perms);
    }
}
 
Example #26
Source File: MainActivity.java    From opentok-android-sdk-samples with MIT License 5 votes vote down vote up
@AfterPermissionGranted(RC_VIDEO_APP_PERM)
private void requestPermissions() {
    String[] perms = { Manifest.permission.INTERNET, Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO };
    if (EasyPermissions.hasPermissions(this, perms)) {
        mSession = new Session.Builder(MainActivity.this, OpenTokConfig.API_KEY, OpenTokConfig.SESSION_ID).build();
        mSession.setSessionListener(this);
        mSession.connect(OpenTokConfig.TOKEN);
    } else {
        EasyPermissions.requestPermissions(this, getString(R.string.rationale_video_app), RC_VIDEO_APP_PERM, perms);
    }
}
 
Example #27
Source File: ConfigActivity.java    From Field-Book with GNU General Public License v2.0 5 votes vote down vote up
@AfterPermissionGranted(PERMISSIONS_REQUEST_DATABASE_IMPORT)
public void importDatabaseFilePermission() {
    String[] perms = {Manifest.permission.READ_EXTERNAL_STORAGE};
    if (EasyPermissions.hasPermissions(this, perms)) {
        showDatabaseImportDialog();
    } else {
        // Do not have permissions, request them now
        EasyPermissions.requestPermissions(this, getString(R.string.permission_rationale_storage_import),
                PERMISSIONS_REQUEST_DATABASE_IMPORT, perms);
    }
}
 
Example #28
Source File: FieldEditorActivity.java    From Field-Book with GNU General Public License v2.0 5 votes vote down vote up
@AfterPermissionGranted(PERMISSIONS_REQUEST_STORAGE)
public void loadLocalPermission() {
    String[] perms = {Manifest.permission.READ_EXTERNAL_STORAGE};
    if (EasyPermissions.hasPermissions(this, perms)) {
        loadLocal();
    } else {
        // Do not have permissions, request them now
        EasyPermissions.requestPermissions(this, getString(R.string.permission_rationale_storage_import),
                PERMISSIONS_REQUEST_STORAGE, perms);
    }

}
 
Example #29
Source File: ConfigActivity.java    From Field-Book with GNU General Public License v2.0 5 votes vote down vote up
@AfterPermissionGranted(PERMISSIONS_REQUEST_LOCATION)
private void locationDialogPermission() {
    String[] perms = {Manifest.permission.ACCESS_FINE_LOCATION};
    if (EasyPermissions.hasPermissions(this, perms)) {
        showLocationDialog();
    } else {
        // Do not have permissions, request them now
        EasyPermissions.requestPermissions(this, getString(R.string.permission_rationale_location),
                PERMISSIONS_REQUEST_LOCATION, perms);
    }
}
 
Example #30
Source File: SettingsFragmentView.java    From FastAccess with GNU General Public License v3.0 5 votes vote down vote up
@AfterPermissionGranted(ActivityHelper.SELECT_PHOTO_REQUEST) private void pickImage() {
    if (EasyPermissions.hasPermissions(getContext(), permissions)) {
        ActivityHelper.startGalleryIntent(this);
    } else {
        EasyPermissions.requestPermissions(this, getString(R.string.write_sdcard_explanation),
                ActivityHelper.SELECT_PHOTO_REQUEST, permissions);
    }
}