本文整理汇总了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();
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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");
}
示例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);
}
示例14: isAvailable
import android.content.pm.PackageManager; //导入方法依赖的package包/类
public boolean isAvailable() {
PackageManager packageManager = getContext().getPackageManager();
return packageManager.hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS);
}
示例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);
}