Android : How To Check If Device Has Camera

In Android, you can use PackageManager , hasSystemFeature() method to check if a device has camera, gps or other features.

See full example of using PackageManager in an activity class.


import android.content.Context;
import android.os.Bundle;
import android.util.Log;

public class FlashLightActivity extends Activity {

	public void onCreate(Bundle savedInstanceState) {

		Context context = this;
		PackageManager packageManager = context.getPackageManager();

		// if device support camera?
		if (packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
			Log.i("camera", "This device has camera!");
			Log.i("camera", "This device has no camera!");

Camera flashlight example
You may interest on this example – How to turn on/off camera LED/flashlight in Android.

One thought on “Android : How To Check If Device Has Camera

  1. cree led k8 January 12, 2013 at 12:41 am Reply

    I think the admin of this web page is in fact working hard
    in support of his site, since here every data is quality
    based data.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: