當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。