Java Code Examples for android.content.pm.PackageManager.getSystemAvailableFeatures()

The following are Jave code examples for showing how to use getSystemAvailableFeatures() of the android.content.pm.PackageManager class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: GitHub   File: CrashDetails.java   View Source Code Vote up 6 votes
/**
 * Returns the current device openGL version.
 */
static String getOpenGL(Context context) {
    PackageManager packageManager = context.getPackageManager();
    FeatureInfo[] featureInfos = packageManager.getSystemAvailableFeatures();
    if (featureInfos != null && featureInfos.length > 0) {
        for (FeatureInfo featureInfo : featureInfos) {
            // Null feature name means this feature is the open gl es version feature.
            if (featureInfo.name == null) {
                if (featureInfo.reqGlEsVersion != FeatureInfo.GL_ES_VERSION_UNDEFINED) {
                    return Integer.toString((featureInfo.reqGlEsVersion & 0xffff0000) >> 16);
                } else {
                    return "1"; // Lack of property means OpenGL ES version 1
                }
            }
        }
    }
    return "1";
}
 
Example 2
Project: utilsLibrary   File: DeviceInfo.java   View Source Code Vote up 6 votes
/**
 * 判断是否支持闪光灯
 *
 * @return true 支持,false 不支持
 */
public static boolean isSupportCameraLedFlash() {
    PackageManager pm = UtilManager.getContext().getPackageManager();
    if (pm != null) {
        FeatureInfo[] features = pm.getSystemAvailableFeatures();
        if (features != null) {
            for (FeatureInfo f : features) {
                //判断设备是否支持闪光灯
                if (f != null && PackageManager.FEATURE_CAMERA_FLASH.equals(f.name)) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
Example 3
Project: WeiXinRecordedDemo   File: DeviceUtils.java   View Source Code Vote up 5 votes
/** 判断是否支持闪光灯 */
public static boolean isSupportCameraLedFlash(PackageManager pm) {
    if (pm != null) {
        FeatureInfo[] features = pm.getSystemAvailableFeatures();
        if (features != null) {
            for (FeatureInfo f : features) {
                if (f != null && PackageManager.FEATURE_CAMERA_FLASH.equals(f.name)) //判断设备是否支持闪光灯
                    return true;
            }
        }
    }
    return false;
}
 
Example 4
Project: WeiXinRecordedDemo   File: DeviceUtils.java   View Source Code Vote up 5 votes
/** 判断是否支持闪光灯 */
public static boolean isSupportCameraLedFlash(PackageManager pm) {
    if (pm != null) {
        FeatureInfo[] features = pm.getSystemAvailableFeatures();
        if (features != null) {
            for (FeatureInfo f : features) {
                if (f != null && PackageManager.FEATURE_CAMERA_FLASH.equals(f.name)) //判断设备是否支持闪光灯
                    return true;
            }
        }
    }
    return false;
}
 
Example 5
Project: AliZhiBoHao   File: CommonUtils.java   View Source Code Vote up 5 votes
public static boolean isSupportCameraLedFlash(PackageManager pm) {
    if (pm != null) {
        FeatureInfo[] features = pm.getSystemAvailableFeatures();
        if (features != null) {
            for (FeatureInfo f : features) {
                if (f != null && PackageManager.FEATURE_CAMERA_FLASH.equals(f.name))
                    return true;
            }
        }
    }
    return false;
}
 
Example 6
Project: PlayAndroid   File: MainActivity.java   View Source Code Vote up 5 votes
@Override
protected void initView() {
    ShortCutUtil.addShortcut(getApplicationContext());

    new RevealEffectUtil().createEnterRevealEffect(this);

    mToolbar.setLogo(R.drawable.vector_user_default_logo);
    mToolbar.setTitleMarginStart(30);
    setToolbarTitle(getString(R.string.nav_home_page));

    mDrawerLayout = findView(R.id.drawer_layout);

    mToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, 0, 0);

    NavigationView navigationView = findView(R.id.navigation_view);
    navigationView.setNavigationItemSelectedListener(this);
    ImageView userLogo = (ImageView) navigationView.findViewById(R.id.nav_user_logo);


    mToggle.syncState();
    mDrawerLayout.addDrawerListener(mToggle);

    PackageManager pm = getPackageManager();

    FeatureInfo[] features = pm.getSystemAvailableFeatures(); //得到所有支援的硬件种类
    Log.d(TAG, "initView: feature:size:" + (features == null));
    for (FeatureInfo feature : features) {
        if (feature != null) {
            String name = feature.name;
            if (TextUtils.isEmpty(name)) {
                Log.v(TAG, "name2: " + feature.reqGlEsVersion);
            } else {
                Log.v(TAG, "name1: " + feature.name);
            }
        } else {
            Log.d(TAG, "空!");
        }
    }

}
 
Example 7
Project: meipai-Android   File: DeviceUtils.java   View Source Code Vote up 5 votes
/** 判断是否支持闪光灯 */
public static boolean isSupportCameraLedFlash(PackageManager pm) {
    if (pm != null) {
        FeatureInfo[] features = pm.getSystemAvailableFeatures();
        if (features != null) {
            for (FeatureInfo f : features) {
                if (f != null && PackageManager.FEATURE_CAMERA_FLASH.equals(f.name)) //判断设备是否支持闪光灯
                    return true;
            }
        }
    }
    return false;
}