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


Java Settings.canDrawOverlays方法代码示例

本文整理汇总了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;
    }


}
 
开发者ID:marckregio,项目名称:maklib,代码行数:20,代码来源:Permissions.java

示例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);
    }
}
 
开发者ID:sonnylazuardi,项目名称:react-native-image-intent,代码行数:17,代码来源:MainActivity.java

示例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);
    }
}
 
开发者ID:cheenid,项目名称:FLFloatingButton,代码行数:27,代码来源:FloatingViewControlFragment.java

示例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);
    }
}
 
开发者ID:cheenid,项目名称:FLFloatingButton,代码行数:27,代码来源:FloatingViewControlFragment.java

示例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();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:19,代码来源:ReactActivityDelegate.java

示例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();
        }
    }
}
 
开发者ID:tranleduy2000,项目名称:text_converter,代码行数:11,代码来源:FloatingCodecCreateShortCutActivity.java

示例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();
}
 
开发者ID:rome753,项目名称:ActivityTaskView,代码行数:11,代码来源:RequestOverlayActivity.java

示例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));
    }
}
 
开发者ID:Rai220,项目名称:Telephoto,代码行数:32,代码来源:SettingsActivity.java

示例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;
    }
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:13,代码来源:permissionManager.java

示例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);
            }
        }
    }
}
 
开发者ID:gicheonkang,项目名称:fast_face_android,代码行数:15,代码来源:CameraActivity.java

示例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();
    }
}
 
开发者ID:Lekky71,项目名称:WhatsAppStatusSaver,代码行数:14,代码来源:MainActivity.java

示例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();
        }
    }

}
 
开发者ID:kav0rka,项目名称:VennTracker,代码行数:29,代码来源:MapsActivity.java

示例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();
        }
    }
}
 
开发者ID:tranleduy2000,项目名称:floating_calc,代码行数:11,代码来源:CreateShortcutActivity.java

示例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();
            }
        }
    }
}
 
开发者ID:kav0rka,项目名称:VennTracker,代码行数:15,代码来源:MapsActivity.java

示例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);
}
 
开发者ID:tatocaster,项目名称:BuildNumberOverlay,代码行数:9,代码来源:AccessPermissionActivity.java


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