本文整理汇总了Java中com.afollestad.assent.Assent.isPermissionGranted方法的典型用法代码示例。如果您正苦于以下问题:Java Assent.isPermissionGranted方法的具体用法?Java Assent.isPermissionGranted怎么用?Java Assent.isPermissionGranted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.afollestad.assent.Assent
的用法示例。
在下文中一共展示了Assent.isPermissionGranted方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onClickFab
import com.afollestad.assent.Assent; //导入方法依赖的package包/类
@OnClick(R.id.fab)
public void onClickFab() {
if (!Assent.isPermissionGranted(Assent.WRITE_EXTERNAL_STORAGE)) {
Assent.requestPermissions(
results -> {
if (results.allPermissionsGranted()) {
request.send().subscribe();
} else {
Snackbar.make(rootView, R.string.permission_denied, Snackbar.LENGTH_LONG).show();
}
},
69,
Assent.WRITE_EXTERNAL_STORAGE);
return;
}
request.send().subscribe();
}
示例2: grantExternalStoragePermission
import com.afollestad.assent.Assent; //导入方法依赖的package包/类
public void grantExternalStoragePermission() {
if (!Assent.isPermissionGranted(Assent.WRITE_EXTERNAL_STORAGE)) {
Assent.requestPermissions(new AssentCallback() {
@Override
public void onPermissionResult(PermissionResultSet result) {
if (result.isGranted(Assent.WRITE_EXTERNAL_STORAGE)) {
startDownload();
} else {
Snackbar.make(ivPreview, R.string.please_accept_write_external_storage_permission, Snackbar.LENGTH_LONG).show();
}
}
}, 5, Assent.WRITE_EXTERNAL_STORAGE);
} else {
startDownload();
}
}
示例3: grantExternalStoragePermission
import com.afollestad.assent.Assent; //导入方法依赖的package包/类
private void grantExternalStoragePermission() {
if (!Assent.isPermissionGranted(Assent.WRITE_EXTERNAL_STORAGE)) {
Assent.requestPermissions(new AssentCallback() {
@Override
public void onPermissionResult(PermissionResultSet result) {
if (result.isGranted(Assent.WRITE_EXTERNAL_STORAGE)) {
startDownload();
} else {
Snackbar.make(ivPreview, R.string.please_accept_write_external_storage_permission, Snackbar.LENGTH_LONG).show();
}
}
}, 5, Assent.WRITE_EXTERNAL_STORAGE);
} else {
startDownload();
}
}
示例4: onCreate
import com.afollestad.assent.Assent; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setup);
((SpeculumApplication) getApplication()).createSetupComponent(this).inject(this);
ButterKnife.bind(this);
Assent.setActivity(this, this);
if (!Assent.isPermissionGranted(Assent.READ_CALENDAR)) {
Assent.requestPermissions(result -> {
// Permission granted or denied
if (!result.allPermissionsGranted()) {
Toast.makeText(SetupActivity.this, noPermissionForCalendar, Toast.LENGTH_SHORT).show();
}
}, 1, Assent.READ_CALENDAR);
}
cbVoiceCommands.setOnCheckedChangeListener(this);
rbSimpleLayout.setOnCheckedChangeListener(this);
}
示例5: onCheckedChanged
import com.afollestad.assent.Assent; //导入方法依赖的package包/类
@Override
@SuppressWarnings("all")
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (buttonView.getId() == R.id.cb_voice_commands) {
if (isChecked) {
if (!Assent.isPermissionGranted(Assent.RECORD_AUDIO)) {
Assent.requestPermissions(result -> {
// Permission granted or denied
if (!result.allPermissionsGranted()) {
Toast.makeText(SetupActivity.this, noPermissionForVoice, Toast.LENGTH_SHORT).show();
cbVoiceCommands.setChecked(false);
}
}, 2, Assent.RECORD_AUDIO);
}
}
} else {
if (isChecked) {
etSubreddit.setVisibility(View.GONE);
tvRedditTitle.setVisibility(View.GONE);
} else {
etSubreddit.setVisibility(View.VISIBLE);
tvRedditTitle.setVisibility(View.VISIBLE);
}
}
}
示例6: askPermissions
import com.afollestad.assent.Assent; //导入方法依赖的package包/类
private void askPermissions() {
if (!Assent.isPermissionGranted(Assent.ACCESS_COARSE_LOCATION) ||
!Assent.isPermissionGranted(Assent.ACCESS_FINE_LOCATION)) {
if (!mPermissionAsked) {
Assent.requestPermissions(this, REQUEST_PERMISSIONS,
Assent.ACCESS_COARSE_LOCATION,
Assent.ACCESS_FINE_LOCATION);
mPermissionAsked = true;
}
}
else {
if (mMap != null)
mMap.setMyLocationEnabled(true);
requestLocation();
}
}
示例7: startRecording
import com.afollestad.assent.Assent; //导入方法依赖的package包/类
void startRecording() {
// ask parent to stop all sounds
if (mListener != null)
mListener.stopAllSounds();
if (!Assent.isPermissionGranted(Assent.READ_EXTERNAL_STORAGE) ||
!Assent.isPermissionGranted(Assent.WRITE_EXTERNAL_STORAGE) ||
!Assent.isPermissionGranted(Assent.RECORD_AUDIO)) {
Assent.requestPermissions(this, REQUEST_PERMISSIONS,
Assent.READ_EXTERNAL_STORAGE,
Assent.WRITE_EXTERNAL_STORAGE,
Assent.RECORD_AUDIO);
}
else {
doStartRecording();
}
}
示例8: askPermissions
import com.afollestad.assent.Assent; //导入方法依赖的package包/类
private void askPermissions() {
if (mPermissionsAsked)
return;
if (!Assent.isPermissionGranted(Assent.READ_CONTACTS) ||
!Assent.isPermissionGranted(Assent.WRITE_CONTACTS)) {
Assent.requestPermissions(new AssentCallback() {
@Override
public void onPermissionResult(PermissionResultSet result) {
// we can go by write contacts denied, but not read contacts
if (!result.isGranted(Assent.READ_CONTACTS)) {
// just notify the user for now, we'll ask again later
error(R.string.err_validation_contacts_denied);
}
}
}, REQUEST_PERMISSIONS, Assent.READ_CONTACTS, Assent.WRITE_CONTACTS);
mPermissionsAsked = true;
}
}
示例9: onCreate
import com.afollestad.assent.Assent; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mTimeTxt = findViewById(R.id.time);
mTimeTxt.setText(DateUtils.formatElapsedTime(0));
mHintTxt = findViewById(R.id.hint);
mImageButton = findViewById(R.id.image_audio);
mProgressBar = findViewById(R.id.circularSeekBar);
mProgressBar.setMax(MAX_PROGRESS);
mProgressBar.setVisibility(View.INVISIBLE);
getButton(Dialog.BUTTON_POSITIVE).setVisibility(View.GONE);
if (!Assent.isPermissionGranted(Assent.READ_EXTERNAL_STORAGE) ||
!Assent.isPermissionGranted(Assent.WRITE_EXTERNAL_STORAGE) ||
!Assent.isPermissionGranted(Assent.RECORD_AUDIO)) {
Assent.requestPermissions(this, REQUEST_PERMISSIONS,
Assent.READ_EXTERNAL_STORAGE,
Assent.WRITE_EXTERNAL_STORAGE,
Assent.RECORD_AUDIO);
}
}
示例10: onCreate
import com.afollestad.assent.Assent; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Bluetooth check
verifyBluetooth();
beaconManager = BeaconManager.getInstanceForApplication(getActivity());
//BEACON PARSER
// beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout(BeaconParser.ALTBEACON_LAYOUT));
// Detect the main identifier (UID) frame:
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout(BeaconParser.EDDYSTONE_UID_LAYOUT));
// Detect the telemetry (TLM) frame:
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout(BeaconParser.EDDYSTONE_TLM_LAYOUT));
// Detect the URL frame:
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout(BeaconParser.EDDYSTONE_URL_LAYOUT));
// Detect parser for iBeacons;
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
// beaconManager.debug = true;
beaconHashMap = new HashMap<String, BeaconUtil>();
if (!Assent.isPermissionGranted(Assent.ACCESS_COARSE_LOCATION)) {
requestLocationPermission();
}
}
示例11: onInstall
import com.afollestad.assent.Assent; //导入方法依赖的package包/类
@OnClick(R.id.fabInstall)
public void onInstall() {
mFabInstall.hide();
if (!Assent.isPermissionGranted(Assent.WRITE_EXTERNAL_STORAGE)) {
Assent.requestPermissions(
permissionResultSet -> {
if (permissionResultSet.allPermissionsGranted()) {
checkInstalled();
} else {
new MaterialDialog.Builder(getActivity())
.title(R.string.permission_needed)
.content(
Html.fromHtml(
getString(
R.string.permission_needed_zooper_desc,
getString(R.string.app_name))))
.positiveText(android.R.string.ok)
.onPositive(
(dialog, which) ->
Assent.requestPermissions(
ZooperFragment.this, PERM_RQ, Assent.WRITE_EXTERNAL_STORAGE))
.show();
}
},
PERM_RQ,
Assent.WRITE_EXTERNAL_STORAGE);
} else {
checkInstalled();
}
}
示例12: onScanButtonClick
import com.afollestad.assent.Assent; //导入方法依赖的package包/类
@OnClick({R.id.start_scan_button, R.id.stop_scan_button, R.id.scan_circle})
void onScanButtonClick() {
if (preferences.getBoolean("key_logging", false) && !Assent.isPermissionGranted(Assent.WRITE_EXTERNAL_STORAGE)) {
requestWriteStoragePermission();
} else if (!Assent.isPermissionGranted(Assent.ACCESS_COARSE_LOCATION)) {
requestLocationPermission();
} else {
if (mode == SCANNING) toggleScanning();
else toggleTransmitting();
}
}
示例13: onCreate
import com.afollestad.assent.Assent; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mStatus = (TextView) findViewById(R.id.status);
if (Assent.isPermissionGranted(Assent.WRITE_EXTERNAL_STORAGE)) {
mStatus.setText(R.string.permission_granted);
} else {
mStatus.setText(R.string.permission_is_not_granted);
}
findViewById(R.id.requestPermission)
.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
Assent.requestPermissions(
new AssentCallback() {
@Override
public void onPermissionResult(PermissionResultSet result) {
if (result.allPermissionsGranted())
mStatus.setText(R.string.permission_granted);
else mStatus.setText(R.string.permission_is_not_granted);
}
},
69,
Assent.WRITE_EXTERNAL_STORAGE);
}
});
}
示例14: askPermissions
import com.afollestad.assent.Assent; //导入方法依赖的package包/类
private void askPermissions() {
if (!Assent.isPermissionGranted(Assent.ACCESS_COARSE_LOCATION) ||
!Assent.isPermissionGranted(Assent.ACCESS_FINE_LOCATION)) {
if (!mPermissionAsked) {
Assent.requestPermissions(this, REQUEST_PERMISSIONS,
Assent.ACCESS_COARSE_LOCATION,
Assent.ACCESS_FINE_LOCATION);
mPermissionAsked = true;
}
}
else {
requestLocation();
}
}
示例15: onResume
import com.afollestad.assent.Assent; //导入方法依赖的package包/类
@Override
protected void onResume() {
super.onResume();
Assent.setActivity(this, this);
mScannerView.setResultHandler(this);
if (Assent.isPermissionGranted(Assent.CAMERA)) {
startCamera();
}
else {
Assent.requestPermissions(this, REQUEST_PERMISSIONS, Assent.CAMERA);
}
}