本文整理了Java中android.provider.Settings
类的一些代码示例,展示了Settings
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Settings
类的具体详情如下:
包路径:android.provider.Settings
类名称:Settings
暂无
代码示例来源:origin: CarGuo/GSYVideoPlayer
@RequiresApi(api = Build.VERSION_CODES.M)
public static boolean hasPermission(Context context) {
return Settings.canDrawOverlays(context);
}
代码示例来源:origin: jiajunhui/PlayerBase
public static boolean checkPermission(Activity activity){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& !Settings.canDrawOverlays(activity)) {
Toast.makeText(activity, "当前无权限,请授权", Toast.LENGTH_SHORT).show();
activity.startActivityForResult(
new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + activity.getPackageName())), 0);
return false;
}
return true;
}
代码示例来源:origin: TeamNewPipe/NewPipe
/**
* In order to be able to draw over other apps, the permission android.permission.SYSTEM_ALERT_WINDOW have to be granted.
* <p>
* On < API 23 (MarshMallow) the permission was granted when the user installed the application (via AndroidManifest),
* on > 23, however, it have to start a activity asking the user if he agrees.
* <p>
* This method just return if the app has permission to draw over other apps, and if it doesn't, it will try to get the permission.
*
* @return returns {@link Settings#canDrawOverlays(Context)}
**/
@RequiresApi(api = Build.VERSION_CODES.M)
public static boolean checkSystemAlertWindowPermission(Context context) {
if (!Settings.canDrawOverlays(context)) {
Intent i = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + context.getPackageName()));
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
return false;
}else return true;
}
代码示例来源:origin: yhaolpz/FloatWindow
static boolean hasPermission(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return Settings.canDrawOverlays(context);
} else {
return hasPermissionBelowMarshmallow(context);
}
}
代码示例来源:origin: commonsguy/cw-omnibus
public void setAdapter(RecyclerView.Adapter adapter) {
boolean canDrawOverlays=
(Build.VERSION.SDK_INT<=Build.VERSION_CODES.LOLLIPOP_MR1);
if (!canDrawOverlays && Build.VERSION.SDK_INT>=Build.VERSION_CODES.M) {
canDrawOverlays=Settings.canDrawOverlays(this);
}
if (BuildConfig.DEBUG && canDrawOverlays) {
adapter=new TimingWrapper(adapter, this);
}
getRecyclerView().setAdapter(adapter);
}
代码示例来源:origin: jiajunhui/PlayerBase
public static void onActivityResult(Activity activity,
int requestCode,
int resultCode,
Intent data,
OnWindowPermissionListener onWindowPermissionListener) {
if (requestCode == 0) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& !Settings.canDrawOverlays(activity)) {
Toast.makeText(activity.getApplicationContext(), "授权失败", Toast.LENGTH_SHORT).show();
if(onWindowPermissionListener!=null)
onWindowPermissionListener.onFailure();
}else {
Toast.makeText(activity.getApplicationContext(), "授权成功", Toast.LENGTH_SHORT).show();
if(onWindowPermissionListener!=null)
onWindowPermissionListener.onSuccess();
}
}
}
代码示例来源:origin: yhaolpz/FloatWindow
static boolean hasPermissionOnActivityResult(Context context) {
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.O) {
return hasPermissionForO(context);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return Settings.canDrawOverlays(context);
} else {
return hasPermissionBelowMarshmallow(context);
}
}
代码示例来源:origin: xfumihiro/ViewInspector
@Around("activityOnCreatedCall()")
public Object injectViewInspector(ProceedingJoinPoint joinPoint) throws Throwable {
Log.d(ViewInspector.TAG, "injectViewInspector");
Context context = (Context) joinPoint.getThis();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (Settings.canDrawOverlays(context)) {
mViewInspector.onCreate(context);
isRestarting = false;
} else {
isRequestingOverlayPermission = true;
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
((Activity) context).startActivityForResult(intent, OVERLAY_PERMISSION_CALL);
}
} else {
mViewInspector.onCreate(context);
}
return joinPoint.proceed();
}
代码示例来源:origin: xfumihiro/ViewInspector
@Around("activityOnResumeCall()") public Object showViewInspector(ProceedingJoinPoint joinPoint)
throws Throwable {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Context context = (Context) joinPoint.getThis();
if (isRequestingOverlayPermission) {
if (Settings.canDrawOverlays(context)) {
// relaunching the app for deploying Probe features
Intent intent =
context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
((Activity) context).finish();
isRequestingOverlayPermission = false;
isRestarting = true;
context.startActivity(intent);
}
} else {
mViewInspector.onResume();
}
} else {
mViewInspector.onResume();
}
return joinPoint.proceed();
}
代码示例来源:origin: eleme/UETool
private boolean showMenu(int y) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!Settings.canDrawOverlays(Application.getApplicationContext())) {
requestPermission(Application.getApplicationContext());
Toast.makeText(Application.getApplicationContext(), "After grant this permission, re-enable UETool", Toast.LENGTH_LONG).show();
return false;
}
}
if (uetMenu == null) {
uetMenu = new UETMenu(Application.getApplicationContext(), y);
}
uetMenu.show();
return true;
}
代码示例来源:origin: k0shk0sh/PermissionHelper
/**
* @return true if {@link Manifest.permission#SYSTEM_ALERT_WINDOW} is granted
*/
public boolean isSystemAlertGranted() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return Settings.canDrawOverlays(context);
}
return true;
}
代码示例来源:origin: k0shk0sh/PermissionHelper
/**
* @return true if {@link android.Manifest.permission#SYSTEM_ALERT_WINDOW} is granted
*/
public static boolean isSystemAlertGranted(@NonNull Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return Settings.canDrawOverlays(context);
}
return true;
}
代码示例来源:origin: k0shk0sh/PermissionHelper
/**
* @return true if {@link Manifest.permission#SYSTEM_ALERT_WINDOW} is granted
*/
public boolean isSystemAlertGranted() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return Settings.canDrawOverlays(context.getContext());
}
return true;
}
代码示例来源:origin: k0shk0sh/PermissionHelper
/**
* @return true if {@link Manifest.permission#SYSTEM_ALERT_WINDOW} is granted
*/
public static boolean isSystemAlertGranted(@NonNull Fragment context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return Settings.canDrawOverlays(context.getContext());
}
return true;
}
代码示例来源:origin: recruit-lifestyle/FloatingView
/**
* FloatingViewの表示
*
* @param context Context
* @param isShowOverlayPermission 表示できなかった場合に表示許可の画面を表示するフラグ
* @param isCustomFloatingView If true, it launches CustomFloatingViewService.
*/
@SuppressLint("NewApi")
private void showFloatingView(Context context, boolean isShowOverlayPermission, boolean isCustomFloatingView) {
// API22以下かチェック
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
startFloatingViewService(getActivity(), isCustomFloatingView);
return;
}
// 他のアプリの上に表示できるかチェック
if (Settings.canDrawOverlays(context)) {
startFloatingViewService(getActivity(), isCustomFloatingView);
return;
}
// オーバレイパーミッションの表示
if (isShowOverlayPermission) {
final Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + context.getPackageName()));
startActivityForResult(intent, isCustomFloatingView ? CUSTOM_OVERLAY_PERMISSION_REQUEST_CODE : CHATHEAD_OVERLAY_PERMISSION_REQUEST_CODE);
}
}
代码示例来源:origin: henrychuangtw/Android-ChatHead
public static boolean canDrawOverlays(Context context){
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return true;
}else{
return Settings.canDrawOverlays(context);
}
}
代码示例来源:origin: 24Kshign/SuspensionWindow
public static boolean checkFloatWindowPermission(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return Settings.canDrawOverlays(context);
}
return true;
}
代码示例来源:origin: moz1q1/WalleLibrary
@SuppressLint("NewApi")
public static boolean canDrawOverlays(Context context) {
return Settings.canDrawOverlays(context);
}
}
代码示例来源:origin: ksvc/KSYMediaPlayer_Android
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == OVERLAY_PERMISSION_RESULT_CODE) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
if (!Settings.canDrawOverlays(this))
Toast.makeText(this, "Permission SYSTEM_ALERT_WINDOW not granted", Toast.LENGTH_SHORT).show();
}
}
代码示例来源:origin: fashare2015/ActivityTracker
@TargetApi(Build.VERSION_CODES.M)
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_CODE && !Settings.canDrawOverlays(this)) {
checkOverlayPermission();
}
}
}
内容来源于网络,如有侵权,请联系作者删除!