Today I tried some ideas with camera in Android and found that there is an easy way to check if camera presents in Android device. Here I am going to show example which shows how to check it.
Example:
import android.app.Activity;import android.os.Bundle;import android.util.Log;public class Main extends Activity{private static String APP_TAG = "tag";private android.hardware.Camera camera;@Overridepublic void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.main);try{camera = android.hardware.Camera.open()} catch (Exception e){Log.e(APP_TAG,e.getMessage())}}}Note:don’t forget to add
<uses-feature android:name="android.hardware.camera" android:required="false"/>
and
<uses-permission android:name="android.permission.CAMERA" />
in AndroidManifest.xml file.
If you’d like to get the latest posts as soon as they’re published,subscribe to our feed!
No related posts.

Recent Comments