2

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.

Kris Selbekk
  • 7,438
  • 7
  • 46
  • 73
  • Use answer for this question http://stackoverflow.com/questions/6767638/calling-android-native-apis-from-javascript-functions-of-embedded-webview – Alex Klimashevsky Aug 08 '12 at 10:51

1 Answers1

1

You can use

PackageManager pm = context.getPackageManager();

if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
}

For more details

Check if device has a camera?

Community
  • 1
  • 1
Kamal
  • 5,462
  • 8
  • 45
  • 58
  • thanks this worked a treat. However, if I get the string "FEATURE_CAMERA" from a different source, how can I make this work the same way? – Kris Selbekk Aug 08 '12 at 11:29