How to check if device has a given capability? [duplicate]
-
25-06-2021 - |
Question
I am building a webapp, and experimenting with figuring out which capabilities the android device has.
Is there a "capability" or "feature" registry I can look this up in? Take an example: Let's say I need to know whether a device has phone capabilities or perhaps a camera capability. Is there a centralized key store where I can check for these constants?
What I'm trying to create is something to the tune of this:
public String HasCapability(String key) {
return some.mystical.namespace.Capabilities.ContainsKey(key);
}
I'm kind of new to this (I'm a C# guy), so excuse my syntax.
Solution
You can use
PackageManager pm = context.getPackageManager();
if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
}
For more details
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow