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


Java PackageManager.hasSystemFeature方法代码示例

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


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

示例1: hasCamera

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
 * 设备是否有相机
 *
 * @param context
 * @return
 */
public static final boolean hasCamera(Context context) {
    if (_hasCamera == null) {
        PackageManager pckMgr = context
                .getPackageManager();
        boolean flag = pckMgr
                .hasSystemFeature("android.hardware.camera.front");
        boolean flag1 = pckMgr.hasSystemFeature("android.hardware.camera");
        boolean flag2;
        if (flag || flag1)
            flag2 = true;
        else
            flag2 = false;
        _hasCamera = Boolean.valueOf(flag2);
    }
    return _hasCamera.booleanValue();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:DeviceUtils.java

示例2: hasSpeacker

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
     * Used to get if the device has a speacker
     * @return
     */
    public boolean hasSpeacker()
    {
        PackageManager packageManager = this.getPackageManager();
        AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);

// Check whether the device has a speaker.
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            // Check FEATURE_AUDIO_OUTPUT to guard against false positives.
            if (!packageManager.hasSystemFeature(PackageManager.FEATURE_AUDIO_OUTPUT)) {
                return false;
            }

            AudioDeviceInfo[] devices = audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS);
            for (AudioDeviceInfo device : devices) {
                if (device.getType() == AudioDeviceInfo.TYPE_BUILTIN_SPEAKER) {
                    return true;
                }
            }
        }
        return false;
    }
 
开发者ID:kflauri2312lffds,项目名称:Android_watch_magpie,代码行数:26,代码来源:MainActivity.java

示例3: hasCamera

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public static final boolean hasCamera(Context context) {
    if (sHasCamera == null) {
        PackageManager pckMgr = context.getPackageManager();
        boolean flag = pckMgr
                .hasSystemFeature("android.hardware.camera.front");
        boolean flag1 = pckMgr.hasSystemFeature("android.hardware.camera");
        boolean flag2;
        flag2 = flag || flag1;
        sHasCamera = flag2;
    }
    return sHasCamera;
}
 
开发者ID:QMUI,项目名称:QMUI_Android,代码行数:13,代码来源:QMUIDisplayHelper.java

示例4: hasCamera

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public static final boolean hasCamera() {
    if (_hasCamera == null) {
        PackageManager pckMgr = BaseApplication.context()
                .getPackageManager();
        boolean flag = pckMgr
                .hasSystemFeature("android.hardware.camera.front");
        boolean flag1 = pckMgr.hasSystemFeature("android.hardware.camera");
        boolean flag2;
        if (flag || flag1)
            flag2 = true;
        else
            flag2 = false;
        _hasCamera = Boolean.valueOf(flag2);
    }
    return _hasCamera.booleanValue();
}
 
开发者ID:FallenCrood,项目名称:Review-,代码行数:17,代码来源:TDevice.java

示例5: disableDisplayZoomControls

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
 * Disable on-screen zoom controls on devices that support zooming via pinch-to-zoom.
 */
private void disableDisplayZoomControls() {
    PackageManager pm = getContext().getPackageManager();
    boolean supportsMultiTouch =
            pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH) ||
            pm.hasSystemFeature(PackageManager.FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT);

    getSettings().setDisplayZoomControls(!supportsMultiTouch);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:12,代码来源:MessageWebView.java

示例6: isGpsAvailable

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public boolean isGpsAvailable(final Context context) {
    if (gpsAvailable == null) {
        final PackageManager packageManager = context.getPackageManager();
        gpsAvailable = packageManager.hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS);
    }
    return gpsAvailable;
}
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:8,代码来源:GpsManager.java

示例7: hasStepCounter

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public boolean hasStepCounter() {

        PackageManager pm = activity.getPackageManager();

        int currentApiVersion = Build.VERSION.SDK_INT;
        // Check that the device supports the step counter and detector sensors
        return currentApiVersion >= 19
                && pm.hasSystemFeature (PackageManager.FEATURE_SENSOR_STEP_COUNTER)
                && pm.hasSystemFeature(PackageManager.FEATURE_SENSOR_STEP_DETECTOR);

    }
 
开发者ID:StasDoskalenko,项目名称:react-native-google-fit,代码行数:12,代码来源:StepSensor.java

示例8: isAndroidThingsDevice

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
 * @return true if this device is running Android Things.
 *
 * Source: https://stackoverflow.com/a/44171734/112705
 */
private boolean isAndroidThingsDevice(Context context) {
    // We can't use PackageManager.FEATURE_EMBEDDED here as it was only added in API level 26,
    // and we currently target a lower minSdkVersion
    final PackageManager pm = context.getPackageManager();
    boolean isRunningAndroidThings = pm.hasSystemFeature("android.hardware.type.embedded");
    Log.d(TAG, "isRunningAndroidThings: " + isRunningAndroidThings);
    return isRunningAndroidThings;
}
 
开发者ID:androidthings,项目名称:sample-tensorflow-imageclassifier,代码行数:14,代码来源:ImageClassifierActivity.java

示例9: check

import android.content.pm.PackageManager; //导入方法依赖的package包/类
private boolean check(String what, String feature, String permission) {
    boolean ret = false;

    PackageManager pm = getContext().getPackageManager();

    // check if available
    if (!pm.hasSystemFeature(feature)) throw new FeatureNotAvailableException(what);
    if (!getActivity().checkPermission(permission)) throw new PermissionNotGrantedException(what);
    ret = true;

    return ret;
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:13,代码来源:PUI.java

示例10: hasProximitySensor

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public static boolean hasProximitySensor(Context con) {
    if (mHasProximitySensor != null) return mHasProximitySensor;

    try {
        PackageManager pm = con.getPackageManager();
        mHasProximitySensor = pm.hasSystemFeature(PackageManager.FEATURE_SENSOR_PROXIMITY);
        return mHasProximitySensor;
    } catch (Throwable t) {
        mHasProximitySensor = null;
        return false;
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:13,代码来源:Utils.java

示例11: onCreate

import android.content.pm.PackageManager; //导入方法依赖的package包/类
@Override
public void onCreate() {
    Configuration.sFilesDirMemory = getFilesDir();
    Configuration.sFilesDirPathMemory = getFilesDir().getPath();

    Configuration.sCacheDirMemory = getCacheDir();
    Configuration.sCacheDirPathMemory = getCacheDir().getPath();

    super.onCreate();
    LogHelper.verboseLog(TAG,
            "File name: \"" +
                    Thread.currentThread().getStackTrace()[2].getFileName() +
                    "\", Line number: " +
                    Thread.currentThread().getStackTrace()[2].getLineNumber() +
                    ", Class name: \"" +
                    Thread.currentThread().getStackTrace()[2].getClassName() +
                    "\", Method name: \"" +
                    Thread.currentThread().getStackTrace()[2].getMethodName() +
                    "\"");

    Configuration.sApplicationName = getString(R.string.app_name);

    Configuration.sOptionsTabFragmentPageTitle = getString(R.string.options);
    Configuration.sUpdatesTabFragmentPageTitle = getString(R.string.updates);

    Realm.init(this);

    RealmConfiguration realmConfiguration = new RealmConfiguration.Builder().build();

    try {
        Realm.setDefaultConfiguration(realmConfiguration);
    } catch (Exception e) {
        LogHelper.errorLog(TAG, e.getMessage());
        e.printStackTrace();
    }

    PackageManager packageManager = getPackageManager();

    if (packageManager.hasSystemFeature(PackageManager.FEATURE_LOCATION)) {
        LogHelper.infoLog(TAG, "Feature \"" + PackageManager.FEATURE_LOCATION + "\" is available");

        Configuration.sIsFeatureLocationAvailable = true;
    } else {
        LogHelper.warnLog(TAG, "Feature \"" + PackageManager.FEATURE_LOCATION + "\" is not available");

        Configuration.sIsFeatureLocationAvailable = false;
    }
    if (packageManager.hasSystemFeature(PackageManager.FEATURE_LOCATION_NETWORK)) {
        LogHelper.infoLog(TAG, "Feature \"" + PackageManager.FEATURE_LOCATION_NETWORK + "\" is available");

        Configuration.sIsFeatureLocationNetworkAvailable = true;
    } else {
        LogHelper.warnLog(TAG, "Feature \"" + PackageManager.FEATURE_LOCATION_NETWORK + "\" is not available");

        Configuration.sIsFeatureLocationNetworkAvailable = false;
    }
    if (packageManager.hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS)) {
        LogHelper.infoLog(TAG, "Feature \"" + PackageManager.FEATURE_LOCATION_GPS + "\" is available");

        Configuration.sIsFeatureLocationGpsAvailable = true;
    } else {
        LogHelper.warnLog(TAG, "Feature \"" + PackageManager.FEATURE_LOCATION_GPS + "\" is not available");

        Configuration.sIsFeatureLocationGpsAvailable = false;
    }
}
 
开发者ID:n37bl4d3,项目名称:Android-Location-Tracker,代码行数:67,代码来源:BaseApplication.java

示例12: isThingsDevice

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public boolean isThingsDevice(Context context) {
    final PackageManager pm = context.getPackageManager();
    return pm.hasSystemFeature("android.hardware.type.embedded");
}
 
开发者ID:bridgefy,项目名称:bridgefy-android-samples,代码行数:5,代码来源:MainActivity.java

示例13: hasCamera

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
 * 判断设备是否有摄像头
 */
public static boolean hasCamera(Context context) {
    PackageManager packageManager = context.getPackageManager();
    return packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY);

}
 
开发者ID:Loofer,项目名称:Watermark,代码行数:9,代码来源:CameraUtils.java

示例14: isAvailable

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public boolean isAvailable() {
    PackageManager packageManager = getContext().getPackageManager();
    return packageManager.hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS);
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:5,代码来源:PLocation.java

示例15: hasCameraFeature

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
 * Checks whether the device has a camera feature or not.
 *
 * @param context a context to check for camera feature.
 * @return true if the device has a camera feature. false otherwise.
 */
public boolean hasCameraFeature(Context context) {
    PackageManager pm = context.getApplicationContext().getPackageManager();
    return pm.hasSystemFeature(PackageManager.FEATURE_CAMERA);
}
 
开发者ID:GitPhoenix,项目名称:VanGogh,代码行数:11,代码来源:VanConfig.java


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