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


Java ApiCompatibilityUtils.checkPermission方法代码示例

本文整理汇总了Java中org.chromium.base.ApiCompatibilityUtils.checkPermission方法的典型用法代码示例。如果您正苦于以下问题:Java ApiCompatibilityUtils.checkPermission方法的具体用法?Java ApiCompatibilityUtils.checkPermission怎么用?Java ApiCompatibilityUtils.checkPermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.chromium.base.ApiCompatibilityUtils的用法示例。


在下文中一共展示了ApiCompatibilityUtils.checkPermission方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerForBeam

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
/**
 * If the device has NFC, construct a BeamCallback and pass it to Android.
 *
 * @param activity Activity that is sending out beam messages.
 * @param provider Provider that returns the URL that should be shared.
 */
public static void registerForBeam(final Activity activity, final BeamProvider provider) {
    final NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(activity);
    if (nfcAdapter == null) return;
    if (ApiCompatibilityUtils.checkPermission(
            activity, Manifest.permission.NFC, Process.myPid(), Process.myUid())
            == PackageManager.PERMISSION_DENIED) {
        return;
    }
    try {
        final BeamCallback beamCallback = new BeamCallback(activity, provider);
        nfcAdapter.setNdefPushMessageCallback(beamCallback, activity);
        nfcAdapter.setOnNdefPushCompleteCallback(beamCallback, activity);
    } catch (IllegalStateException e) {
        Log.w("BeamController", "NFC registration failure. Can't retry, giving up.");
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:23,代码来源:BeamController.java

示例2: hasGeolocationPermission

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
static boolean hasGeolocationPermission(Context context) {
    int pid = Process.myPid();
    int uid = Process.myUid();
    if (ApiCompatibilityUtils.checkPermission(
            context, Manifest.permission.ACCESS_COARSE_LOCATION, pid, uid)
            != PackageManager.PERMISSION_GRANTED) {
        return false;
    }

    // Work around a bug in OnePlus2 devices running Lollipop, where the NETWORK_PROVIDER
    // incorrectly requires FINE_LOCATION permission (it should only require COARSE_LOCATION
    // permission). http://crbug.com/580733
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M
            && ApiCompatibilityUtils.checkPermission(
                    context, Manifest.permission.ACCESS_FINE_LOCATION, pid, uid)
                    != PackageManager.PERMISSION_GRANTED) {
        return false;
    }

    return true;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:22,代码来源:GeolocationHeader.java

示例3: permissionOnInAndroid

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
/**
 * Returns whether a per-app permission is enabled.
 * @param permission The string of the permission to check.
 */
private boolean permissionOnInAndroid(String permission, Context context) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return true;

    return PackageManager.PERMISSION_GRANTED == ApiCompatibilityUtils.checkPermission(
            context, permission, Process.myPid(), Process.myUid());
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:11,代码来源:SiteSettingsCategory.java

示例4: hasPermission

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
@Override
public boolean hasPermission(String permission) {
    return ApiCompatibilityUtils.checkPermission(
            mApplicationContext, permission, Process.myPid(), Process.myUid())
            == PackageManager.PERMISSION_GRANTED;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:7,代码来源:VrWindowAndroid.java

示例5: checkDebugPermission

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
@CalledByNative
private static boolean checkDebugPermission(Context context, int pid, int uid) {
    String debugPermissionName = context.getPackageName() + DEBUG_PERMISSION_SIFFIX;
    return ApiCompatibilityUtils.checkPermission(context, debugPermissionName, pid, uid)
            == PackageManager.PERMISSION_GRANTED;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:7,代码来源:DevToolsServer.java

示例6: onCreate

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
@SuppressFBWarnings("DM_EXIT")
@SuppressLint("InlinedApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
    ensureActivityNotExported();

    // The browser process must be started here because this Activity may be started explicitly
    // from Android notifications, when Android is restoring Preferences after Chrome was
    // killed, or for tests. This should happen before super.onCreate() because it might
    // recreate a fragment, and a fragment might depend on the native library.
    try {
        ChromeBrowserInitializer.getInstance(this).handleSynchronousStartup();
    } catch (ProcessInitException e) {
        Log.e(TAG, "Failed to start browser process.", e);
        // This can only ever happen, if at all, when the activity is started from an Android
        // notification (or in tests). As such we don't want to show an error messsage to the
        // user. The application is completely broken at this point, so close it down
        // completely (not just the activity).
        System.exit(-1);
        return;
    }

    super.onCreate(savedInstanceState);

    mIsNewlyCreated = savedInstanceState == null;

    String initialFragment = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT);
    Bundle initialArguments = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // If savedInstanceState is non-null, then the activity is being
    // recreated and super.onCreate() has already recreated the fragment.
    if (savedInstanceState == null) {
        if (initialFragment == null) initialFragment = MainPreferences.class.getName();
        Fragment fragment = Fragment.instantiate(this, initialFragment, initialArguments);
        getFragmentManager().beginTransaction()
                .replace(android.R.id.content, fragment)
                .commit();
    }

    if (ApiCompatibilityUtils.checkPermission(
            this, Manifest.permission.NFC, Process.myPid(), Process.myUid())
            == PackageManager.PERMISSION_GRANTED) {
        // Disable Android Beam on JB and later devices.
        // In ICS it does nothing - i.e. we will send a Play Store link if NFC is used.
        NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
        if (nfcAdapter != null) nfcAdapter.setNdefPushMessage(null, this);
    }


    Resources res = getResources();
    ApiCompatibilityUtils.setTaskDescription(this, res.getString(R.string.app_name),
            BitmapFactory.decodeResource(res, R.mipmap.app_icon),
            ApiCompatibilityUtils.getColor(res, R.color.default_primary_color));
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:57,代码来源:Preferences.java


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