FAQS


How To Check Device Has Camera

Views: 3070  |   Date: 2013-08-17 14:01:28

Check Device Has Camera Or Not.

Answer 1

Use PackageManager , hasSystemFeature() method to check if a device has camera, gps or other features.

   
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.Log;
 
public class CheckCamera extends Activity {
 
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//setContentView(R.layout.main);
 
		Context context = this;
		PackageManager packageManager = context.getPackageManager();
 
		// if device support camera?
		if (packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
			//yes
			Log.i("camera", "Camera found!");
		}else{
			//no
			Log.i("camera", "Camera not found!");
		}
 
 
	}
}

 
Submit Your Answer
  |  
 
 
 

Preview :