本文整理汇总了Java中android.provider.Settings.canDrawOverlays方法的典型用法代码示例。如果您正苦于以下问题:Java Settings.canDrawOverlays方法的具体用法?Java Settings.canDrawOverlays怎么用?Java Settings.canDrawOverlays使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.provider.Settings
的用法示例。
在下文中一共展示了Settings.canDrawOverlays方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkDrawOverlayPermission
import android.provider.Settings; //导入方法依赖的package包/类
public boolean checkDrawOverlayPermission() {
/** check if we already have permission to draw over other apps */
if (Build.VERSION.SDK_INT >= 23) {
if (!Settings.canDrawOverlays(activity)) {
/** if not construct intent to request permission */
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + activity.getPackageName()));
/** request permission via start activity for result */
activity.startActivityForResult(intent, SETTINGS_REQUEST_CODE);
return false;
} else {
return true;
}
} else {
return true;
}
}
示例2: onActivityResult
import android.provider.Settings; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == OVERLAY_PERMISSION_REQ_CODE) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!Settings.canDrawOverlays(this)) {
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + getPackageName()));
startActivityForResult(intent, OVERLAY_PERMISSION_REQ_CODE);
} else {
this.initializePage();
}
}
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
示例3: showCustomFloatingView
import android.provider.Settings; //导入方法依赖的package包/类
/**
* カスタマイズFloatingViewの表示
*
* @param context Context
* @param isShowOverlayPermission 表示できなかった場合に表示許可の画面を表示するフラグ
*/
@SuppressLint("NewApi")
private void showCustomFloatingView(Context context, boolean isShowOverlayPermission) {
// API22以下かチェック
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
context.startService(new Intent(context, CustomFloatingViewService.class));
return;
}
// 他のアプリの上に表示できるかチェック
if (Settings.canDrawOverlays(context)) {
context.startService(new Intent(context, CustomFloatingViewService.class));
return;
}
// オーバレイパーミッションの表示
if (isShowOverlayPermission) {
final Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + context.getPackageName()));
startActivityForResult(intent, CUSTOM_OVERLAY_PERMISSION_REQUEST_CODE);
}
}
示例4: showChatHead
import android.provider.Settings; //导入方法依赖的package包/类
/**
* シンプルなFloatingViewの表示
*
* @param context Context
* @param isShowOverlayPermission 表示できなかった場合に表示許可の画面を表示するフラグ
*/
@SuppressLint("NewApi")
private void showChatHead(Context context, boolean isShowOverlayPermission) {
// API22以下かチェック
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
context.startService(new Intent(context, ChatHeadService.class));
return;
}
// 他のアプリの上に表示できるかチェック
if (Settings.canDrawOverlays(context)) {
context.startService(new Intent(context, ChatHeadService.class));
return;
}
// オーバレイパーミッションの表示
if (isShowOverlayPermission) {
final Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + context.getPackageName()));
startActivityForResult(intent, CHATHEAD_OVERLAY_PERMISSION_REQUEST_CODE);
}
}
示例5: onCreate
import android.provider.Settings; //导入方法依赖的package包/类
protected void onCreate(Bundle savedInstanceState) {
boolean needsOverlayPermission = false;
if (getReactNativeHost().getUseDeveloperSupport() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// Get permission to show redbox in dev builds.
if (!Settings.canDrawOverlays(getContext())) {
needsOverlayPermission = true;
Intent serviceIntent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getContext().getPackageName()));
FLog.w(ReactConstants.TAG, REDBOX_PERMISSION_MESSAGE);
Toast.makeText(getContext(), REDBOX_PERMISSION_MESSAGE, Toast.LENGTH_LONG).show();
((Activity) getContext()).startActivityForResult(serviceIntent, REQUEST_OVERLAY_PERMISSION_CODE);
}
}
if (mMainComponentName != null && !needsOverlayPermission) {
loadApp(mMainComponentName);
}
mDoubleTapReloadRecognizer = new DoubleTapReloadRecognizer();
}
示例6: onActivityResult
import android.provider.Settings; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE_WINDOW_OVERLAY_PERMISSION) {
if (android.os.Build.VERSION.SDK_INT < 23 || Settings.canDrawOverlays(this)) {
onSuccess();
} else {
onFailure();
}
}
}
示例7: onActivityResult
import android.provider.Settings; //导入方法依赖的package包/类
@SuppressLint("NewApi")
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 0 && Settings.canDrawOverlays(this)) {
ActivityTask.addWindow(getApplication());
}else{
Toast.makeText(getApplicationContext(), "window permission denied, cannot show activity task", Toast.LENGTH_SHORT).show();
}
finish();
}
示例8: onPostResume
import android.provider.Settings; //导入方法依赖的package包/类
@Override
protected void onPostResume() {
super.onPostResume();
if (!permissionRequested) {
permissionRequested = true;
requestMultiplePermissions();
}
// We can't work withoout overlays
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(this)) {
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + getPackageName()));
startActivityForResult(intent, 123);
} else {
// ((EditText) findViewById(R.id.botTokenEditText)).setText(PrefsController.instance.getToken());
((EditText) findViewById(R.id.botPassword)).setText(PrefsController.instance.getPassword());
((CheckBox) findViewById(R.id.autorunCheckbox)).setChecked(PrefsController.instance.isAutorunEnabled());
if (PrefsController.instance.isPro()) {
findViewById(R.id.proVersionButton).setVisibility(View.GONE);
((ImageView) findViewById(R.id.mainIcon)).setImageResource(R.drawable.icon_pro);
}
if (!PrefsController.instance.isHelpShown()) {
showHelp();
}
LocalBroadcastManager.getInstance(this).registerReceiver(serviceStopReciever, new IntentFilter(TELEPHOTO_SERVICE_STOPPED));
}
}
示例9: isSystemAlertGranted
import android.provider.Settings; //导入方法依赖的package包/类
public static boolean isSystemAlertGranted(@NonNull Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
boolean result = PermissionChecker.checkCallingOrSelfPermission(context, Manifest.permission.SYSTEM_ALERT_WINDOW) == PermissionChecker.PERMISSION_GRANTED;
if (result || Settings.canDrawOverlays(context)) {
return true;
} else {
return false;
}
} else {
return true;
}
}
示例10: onActivityResult
import android.provider.Settings; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == OVERLAY_PERMISSION_REQ_CODE) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!Settings.canDrawOverlays(this.getApplicationContext())) {
Toast.makeText(CameraActivity.this, "CameraActivity\", \"SYSTEM_ALERT_WINDOW, permission not granted...", Toast.LENGTH_SHORT).show();
} else {
Intent intent = getIntent();
finish();
startActivity(intent);
}
}
}
}
示例11: startFloating
import android.provider.Settings; //导入方法依赖的package包/类
public void startFloating() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(this)) {
Toast.makeText(this, "You to allow this app to draw over other apps in order" +
" for the floating circle to work", Toast.LENGTH_LONG).show();
//If the draw over permission is not available open the settings screen
//to grant the permission.
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + getPackageName()));
startActivityForResult(intent, CODE_DRAW_OVER_OTHER_APP_PERMISSION);
} else {
initializeView();
}
}
示例12: checkDrawOverlayPermission
import android.provider.Settings; //导入方法依赖的package包/类
public void checkDrawOverlayPermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!Settings.canDrawOverlays(MapsActivity.this)) {
/** if not construct intent to request permission */
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + getPackageName()));
/** request permission via start activity for result */
startActivityForResult(intent, REQUEST_CODE_OVERLAY);
}
else {
if (mOverlayedButtonGreen.getParent() != null) {
removeOverlay();
}
else {
overlayDialog();
}
}
}
else {
if (mOverlayedButtonGreen.getParent() != null) {
removeOverlay();
}
else {
overlayDialog();
}
}
}
示例13: onActivityResult
import android.provider.Settings; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE_WINDOW_OVERLAY_PERMISSION) {
if (Build.VERSION.SDK_INT >= 23 && Settings.canDrawOverlays(this)) {
onSuccess();
} else {
onFailure();
}
}
}
示例14: onActivityResult
import android.provider.Settings; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
/** check if received result code
is equal our requested code for draw permission */
if (requestCode == REQUEST_CODE_OVERLAY) {
// ** if so check once again if we have permission */
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (Settings.canDrawOverlays(this)) {
// continue here - permission was granted
startOverlay();
}
}
}
}
示例15: isSystemAlertPermissionGranted
import android.provider.Settings; //导入方法依赖的package包/类
/**
* @param context
* @return
*/
@TargetApi(Build.VERSION_CODES.M)
public static boolean isSystemAlertPermissionGranted(Context context) {
return Build.VERSION.SDK_INT < Build.VERSION_CODES.M || Settings.canDrawOverlays(context);
}