List of usage examples for android.content.pm PackageManager FEATURE_CAMERA_FLASH
String FEATURE_CAMERA_FLASH
To view the source code for android.content.pm PackageManager FEATURE_CAMERA_FLASH.
Click Source Link
From source file:com.macleod2486.androidswissknife.views.Toggles.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.toggles, container, false); toggleLight = (Button) view.findViewById(R.id.toggleLight); if (getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)) { toggleLightListener = new Flashlight(getActivity(), CAMERA_CODE); toggleLight.setOnClickListener(toggleLightListener); }// w w w . ja v a2 s . c o m toggleWifi = (Button) view.findViewById(R.id.toggleWifi); if (getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI)) { toggleWifiListener = new Wifi(getActivity()); toggleWifi.setOnClickListener(toggleWifiListener); } toggleLocation = (Button) view.findViewById(R.id.toggleGps); if (getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS)) { location = new Location(getActivity()); toggleLocation.setOnClickListener(location); } return view; }
From source file:Main.java
/** * A single feature that can be requested by an application. * This corresponds to information collected from the AndroidManifest.xml's tag. * @param feature "FeatureInfo"//from www . j a v a 2s . c om */ @SuppressWarnings("deprecation") public static String getFeature(String feature) { if (TextUtils.isEmpty(feature)) { return UNKNOWN; } switch (feature) { case PackageManager.FEATURE_APP_WIDGETS://android.software.app_widgets return "FEATURE_APP_WIDGETS"; case PackageManager.FEATURE_AUDIO_LOW_LATENCY://android.hardware.audio.low_latency return "FEATURE_AUDIO_LOW_LATENCY"; case PackageManager.FEATURE_AUDIO_OUTPUT://android.hardware.audio.output return "FEATURE_AUDIO_OUTPUT"; case PackageManager.FEATURE_AUDIO_PRO://android.hardware.audio.pro return "FEATURE_AUDIO_PRO";//API 23 case PackageManager.FEATURE_AUTOMOTIVE://android.hardware.type.automotive return "FEATURE_AUTOMOTIVE";//API 23 case PackageManager.FEATURE_BACKUP://android.software.backup return "FEATURE_BACKUP"; case PackageManager.FEATURE_BLUETOOTH://android.hardware.bluetooth return "FEATURE_BLUETOOTH"; case PackageManager.FEATURE_BLUETOOTH_LE://android.hardware.bluetooth_le return "FEATURE_BLUETOOTH_LE"; case PackageManager.FEATURE_CAMERA://android.hardware.camera return "FEATURE_CAMERA"; case PackageManager.FEATURE_CAMERA_ANY://android.hardware.camera.any return "FEATURE_CAMERA_ANY"; case PackageManager.FEATURE_CAMERA_AUTOFOCUS://android.hardware.camera.autofocus return "FEATURE_CAMERA_AUTOFOCUS"; case PackageManager.FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING://android.hardware.camera.capability.manual_post_processing return "FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING"; case PackageManager.FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR://android.hardware.camera.capability.manual_sensor return "FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR"; case PackageManager.FEATURE_CAMERA_CAPABILITY_RAW://android.hardware.camera.capability.raw return "FEATURE_CAMERA_CAPABILITY_RAW"; case PackageManager.FEATURE_CAMERA_EXTERNAL://android.hardware.camera.external return "FEATURE_CAMERA_EXTERNAL"; case PackageManager.FEATURE_CAMERA_FLASH://android.hardware.camera.flash return "FEATURE_CAMERA_FLASH"; case PackageManager.FEATURE_CAMERA_FRONT://android.hardware.camera.front return "FEATURE_CAMERA_FRONT"; case PackageManager.FEATURE_CAMERA_LEVEL_FULL://android.hardware.camera.level.full return "FEATURE_CAMERA_LEVEL_FULL"; case PackageManager.FEATURE_CONNECTION_SERVICE://android.software.connectionservice return "FEATURE_CONNECTION_SERVICE"; case PackageManager.FEATURE_CONSUMER_IR://android.hardware.consumerir return "FEATURE_CONSUMER_IR"; case PackageManager.FEATURE_DEVICE_ADMIN://android.software.device_admin return "FEATURE_DEVICE_ADMIN"; case PackageManager.FEATURE_FAKETOUCH://android.hardware.faketouch return "FEATURE_FAKETOUCH"; case PackageManager.FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT://android.hardware.faketouch.multitouch.distinct return "FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT"; case PackageManager.FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND://android.hardware.faketouch.multitouch.jazzhand return "FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND"; case PackageManager.FEATURE_FINGERPRINT://android.hardware.fingerprint return "FEATURE_FINGERPRINT";//API 23 case PackageManager.FEATURE_GAMEPAD://android.hardware.gamepad return "FEATURE_GAMEPAD"; case PackageManager.FEATURE_HIFI_SENSORS://android.hardware.sensor.hifi_sensors return "FEATURE_HIFI_SENSORS";//API 23 case PackageManager.FEATURE_HOME_SCREEN://android.software.home_screen return "FEATURE_HOME_SCREEN"; case PackageManager.FEATURE_INPUT_METHODS://android.software.input_methods return "FEATURE_INPUT_METHODS"; case PackageManager.FEATURE_LEANBACK://android.software.leanback return "FEATURE_LEANBACK"; case PackageManager.FEATURE_LIVE_TV://android.software.live_tv return "FEATURE_LIVE_TV"; case PackageManager.FEATURE_LIVE_WALLPAPER://android.software.live_wallpaper return "FEATURE_LIVE_WALLPAPER"; case PackageManager.FEATURE_LOCATION://android.hardware.location return "FEATURE_LOCATION"; case PackageManager.FEATURE_LOCATION_GPS://android.hardware.location.gps return "FEATURE_LOCATION_GPS"; case PackageManager.FEATURE_LOCATION_NETWORK://android.hardware.location.network return "FEATURE_LOCATION_NETWORK"; case PackageManager.FEATURE_MANAGED_USERS://android.software.managed_users return "FEATURE_MANAGED_USERS"; case PackageManager.FEATURE_MICROPHONE://android.hardware.microphone return "FEATURE_MICROPHONE"; case PackageManager.FEATURE_MIDI://android.software.midi return "FEATURE_MIDI";//API 23 case PackageManager.FEATURE_NFC://android.hardware.nfc return "FEATURE_NFC"; case PackageManager.FEATURE_NFC_HOST_CARD_EMULATION://android.hardware.nfc.hce return "FEATURE_NFC_HOST_CARD_EMULATION"; case PackageManager.FEATURE_OPENGLES_EXTENSION_PACK://android.hardware.opengles.aep return "FEATURE_OPENGLES_EXTENSION_PACK"; case PackageManager.FEATURE_PRINTING://android.software.print return "FEATURE_PRINTING"; case PackageManager.FEATURE_SCREEN_LANDSCAPE://android.hardware.screen.landscape return "FEATURE_SCREEN_LANDSCAPE"; case PackageManager.FEATURE_SCREEN_PORTRAIT://android.hardware.screen.portrait return "FEATURE_SCREEN_PORTRAIT"; case PackageManager.FEATURE_SECURELY_REMOVES_USERS://android.software.securely_removes_users return "FEATURE_SECURELY_REMOVES_USERS"; case PackageManager.FEATURE_SENSOR_ACCELEROMETER://android.hardware.sensor.accelerometer return "FEATURE_SENSOR_ACCELEROMETER"; case PackageManager.FEATURE_SENSOR_AMBIENT_TEMPERATURE://android.hardware.sensor.ambient_temperature return "FEATURE_SENSOR_AMBIENT_TEMPERATURE"; case PackageManager.FEATURE_SENSOR_BAROMETER://android.hardware.sensor.barometer return "FEATURE_SENSOR_BAROMETER"; case PackageManager.FEATURE_SENSOR_COMPASS://android.hardware.sensor.compass return "FEATURE_SENSOR_COMPASS"; case PackageManager.FEATURE_SENSOR_GYROSCOPE://android.hardware.sensor.gyroscope return "FEATURE_SENSOR_GYROSCOPE"; case PackageManager.FEATURE_SENSOR_HEART_RATE://android.hardware.sensor.heartrate return "FEATURE_SENSOR_HEART_RATE"; case PackageManager.FEATURE_SENSOR_HEART_RATE_ECG://android.hardware.sensor.heartrate.ecg return "FEATURE_SENSOR_HEART_RATE_ECG"; case PackageManager.FEATURE_SENSOR_LIGHT://android.hardware.sensor.light return "FEATURE_SENSOR_LIGHT"; case PackageManager.FEATURE_SENSOR_PROXIMITY://android.hardware.sensor.proximity return "FEATURE_SENSOR_PROXIMITY"; case PackageManager.FEATURE_SENSOR_RELATIVE_HUMIDITY://android.hardware.sensor.relative_humidity return "FEATURE_SENSOR_RELATIVE_HUMIDITY"; case PackageManager.FEATURE_SENSOR_STEP_COUNTER://android.hardware.sensor.stepcounter return "FEATURE_SENSOR_STEP_COUNTER"; case PackageManager.FEATURE_SENSOR_STEP_DETECTOR://android.hardware.sensor.stepdetector return "FEATURE_SENSOR_STEP_DETECTOR"; case PackageManager.FEATURE_SIP://android.software.sip return "FEATURE_SIP"; case PackageManager.FEATURE_SIP_VOIP://android.software.sip.voip return "FEATURE_SIP_VOIP"; case PackageManager.FEATURE_TELEPHONY://android.hardware.telephony return "FEATURE_TELEPHONY"; case PackageManager.FEATURE_TELEPHONY_CDMA://android.hardware.telephony.cdma return "FEATURE_TELEPHONY_CDMA"; case PackageManager.FEATURE_TELEPHONY_GSM://android.hardware.telephony.gsm return "FEATURE_TELEPHONY_GSM"; case PackageManager.FEATURE_TELEVISION://android.hardware.type.television return "FEATURE_TELEVISION"; case PackageManager.FEATURE_TOUCHSCREEN://android.hardware.touchscreen return "FEATURE_TOUCHSCREEN"; case PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH://android.hardware.touchscreen.multitouch return "FEATURE_TOUCHSCREEN_MULTITOUCH"; case PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT://android.hardware.touchscreen.multitouch.distinct return "FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT"; case PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND://android.hardware.touchscreen.multitouch.jazzhand return "FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND"; case PackageManager.FEATURE_USB_ACCESSORY://android.hardware.usb.accessory return "FEATURE_USB_ACCESSORY"; case PackageManager.FEATURE_USB_HOST://android.hardware.usb.host return "FEATURE_USB_HOST"; case PackageManager.FEATURE_VERIFIED_BOOT://android.software.verified_boot return "FEATURE_VERIFIED_BOOT"; case PackageManager.FEATURE_WATCH://android.hardware.type.watch return "FEATURE_WATCH"; case PackageManager.FEATURE_WEBVIEW://android.software.webview return "FEATURE_WEBVIEW"; case PackageManager.FEATURE_WIFI://android.hardware.wifi return "FEATURE_WIFI"; case PackageManager.FEATURE_WIFI_DIRECT://android.hardware.wifi.direct return "FEATURE_WIFI_DIRECT"; default: return UNKNOWN; } }
From source file:com.example.lenny.barcodevison.ScanBarcodeActivity.java
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_scan_barcode); buttonFlash = (Button) findViewById(R.id.btnFlash); cameraPreview = (SurfaceView) findViewById(R.id.camera_preview); camManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE); hasFlash = getApplicationContext().getPackageManager() .hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH); if (!hasFlash) { buttonFlash.setVisibility(View.INVISIBLE); } else {//w w w . j a v a 2 s .c om } buttonFlash.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!isFlashOn) { flashLightOn(); buttonFlash.setText("FLASH\nOFF"); } else { flashLightOff(); buttonFlash.setText("FLASH\nON"); } } }); createCameraSource(); }
From source file:piuk.blockchain.android.ui.zxing.CaptureActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setRequestedOrientation(getCurrentOrientation()); Window window = getWindow();// w w w.j av a 2s . co m window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_scan); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_general); setupToolbar(toolbar, R.string.scan_qr); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); hasSurface = false; inactivityTimer = new InactivityTimer(this); hasFlashLight = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH); }
From source file:com.areebbeigh.qrcodeutility.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); switch (id) { case R.id.browse_button: // Only the scan fragment has a browse option ScanFragment f = (ScanFragment) fragmentObj; f.browseImage();//from w w w. ja va 2 s . co m break; case R.id.flash_button: if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)) { Toast.makeText(this, "Your device does not have a camera flash", Toast.LENGTH_LONG).show(); return true; } toggleFlash(); break; } return true; }
From source file:com.example.lenny.barcodevison.ScanBarcodeActivity.java
public void flashLightOn() { try {// w ww . ja v a 2 s.co m if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)) { cam = getCamera(cameraSource); Camera.Parameters p = cam.getParameters(); p.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH); cam.setParameters(p); isFlashOn = true; } } catch (Exception e) { e.printStackTrace(); Toast.makeText(getBaseContext(), "Unable to Light Flash!", Toast.LENGTH_SHORT).show(); } }
From source file:org.akvo.caddisfly.ui.activity.MainActivity.java
private boolean checkCameraFlash() { boolean hasFlash = this.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH); Camera camera = getCameraInstance(); try {// w ww.jav a 2 s. c om Camera.Parameters p; if (hasFlash) { p = camera.getParameters(); if (p.getSupportedFlashModes() == null) { hasFlash = false; } else { if (p.getSupportedFlashModes().size() == 1) { if (p.getSupportedFlashModes().get(0).equals("off")) { hasFlash = false; } } } } } finally { if (camera != null) { camera.release(); } } return hasFlash; }
From source file:com.example.lenny.barcodevison.ScanBarcodeActivity.java
public void flashLightOff() { try {//w w w . ja va2 s . com if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)) { cam = getCamera(cameraSource); Camera.Parameters p = cam.getParameters(); p.setFlashMode(Camera.Parameters.FLASH_MODE_OFF); cam.setParameters(p); isFlashOn = false; } } catch (Exception e) { e.printStackTrace(); Toast.makeText(getBaseContext(), "Unable To Extinguish Flash", Toast.LENGTH_SHORT).show(); } }
From source file:hr.abunicic.angular.CameraActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ApplicationContext.getInstance().init(getApplicationContext()); setContentView(R.layout.activity_camera); //Left drawer drawerLayout = (DrawerLayout) findViewById(R.id.camera_activity_drawer_layout); //Binding the RecyclerView recyclerView = (RecyclerView) findViewById(R.id.r_list); recyclerView.setHasFixedSize(true);//from w w w.j a v a2s. co m //Informative text when database is empty infoNothingSaved = (TextView) findViewById(R.id.infoNothing); //Getting all saved shaped from the database and populating the RecyclerView db = new DatabaseHandler(CameraActivity.this); historyItems = (ArrayList) db.getAllShapes(); setHistoryItems(); //Card at the bottom cardBottom = (CardView) findViewById(R.id.cardBottom); cardBottom.bringToFront(); //Elements inside the CardView tvShape = (TextView) findViewById(R.id.tvGeomLik); tvCardTitle = (TextView) findViewById(R.id.titleText); tvShape.setMovementMethod(new ScrollingMovementMethod()); final ImageButton imgSave = (ImageButton) findViewById(R.id.imgSave); //Getting instance of the sensor service mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); mGyroSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR); //Initializing the camera and setting up screen size initCamera(); DisplayMetrics displayMetrics = new DisplayMetrics(); this.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); screenHeight = displayMetrics.heightPixels; screenWidth = displayMetrics.widthPixels; //Flash button final ImageButton imgFlash = (ImageButton) findViewById(R.id.imgFlash); if (this.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)) { imgFlash.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (params.getFlashMode().equals(Camera.Parameters.FLASH_MODE_TORCH)) { params.setFlashMode(Camera.Parameters.FLASH_MODE_OFF); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { imgFlash.setBackground(getResources().getDrawable(R.drawable.ic_flash_on_white_36dp)); } } else { params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { imgFlash.setBackground(getResources().getDrawable(R.drawable.ic_flash_off_white_36dp)); } } mCamera.setParameters(params); } }); } else { imgFlash.setVisibility(View.GONE); } //Delete all button in the drawer view ImageButton imgDeleteAll = (ImageButton) findViewById(R.id.imgDeleteAll); imgDeleteAll.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { db.deleteAllShapes(); historyItems.clear(); setHistoryItems(); } }); //Menu icon for opening the drawer ImageButton imgMenu = (ImageButton) findViewById(R.id.imgMenu); imgMenu.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { drawerLayout.openDrawer(Gravity.LEFT); } }); //Fab button functionality fabCapture = (FloatingActionButton) findViewById(R.id.fab); fabCapture.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startDetection(); fabCapture.setClickable(false); FabTransformation.with(fabCapture).transformTo(cardBottom); imgSave.setVisibility(View.VISIBLE); imgSave.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Animation animation = AnimationUtils.loadAnimation(CameraActivity.this, R.anim.anim); mCameraView.startAnimation(animation); Toast toast = Toast.makeText(getApplicationContext(), getResources().getString(R.string.toast_saved), Toast.LENGTH_LONG); //Dodati u strings i u engl verziju toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 0); toast.show(); ShapeInDatabase shapeToAdd = new ShapeInDatabase(mCameraView.getBitmap(), tvCardTitle.getText().toString(), tvShape.getText().toString()); db.addShape(shapeToAdd); historyItems.add(0, shapeToAdd); setHistoryItems(); } }); if (rp != null) { Shape shape = ShapeHeuristic.getShape(rp); if (shape != null) { tvCardTitle.setText(shape.getName()); tvShape.setText(shape.toString()); if (shape instanceof DefaultPolygon && ((DefaultPolygon) shape).getN() == 5) { tvCardTitle.setText("Pravilni peterokut"); tvShape.setText( "Sve stranice pravilnog peterokuta su jednake duljine. \n a = 5 cm \n P = 43.01 \n O = 25"); } } } } }); //Button inside the card for going back Button buttonBack = (Button) findViewById(R.id.buttonBack); buttonBack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { startDetection(); FabTransformation.with(fabCapture).transformFrom(cardBottom); fabCapture.setClickable(true); imgSave.setVisibility(View.INVISIBLE); } }); //Button inside the card for opening the ResultActivity with more info about the shape Button buttonMore = (Button) findViewById(R.id.buttonMore); buttonMore.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Shape shape = ShapeHeuristic.getShape(rp); if (shape instanceof DefaultPolygon && ((DefaultPolygon) shape).getN() == 5) { Intent intentPeterokut = new Intent(CameraActivity.this, PeterokutActivity.class); startActivity(intentPeterokut); } else { Intent intent = new Intent(CameraActivity.this, ResultActivity.class); intent.putExtra("RESULT_TITLE", tvCardTitle.getText().toString()); intent.putExtra("RESULT_INFO", tvShape.getText().toString()); ByteArrayOutputStream bos = new ByteArrayOutputStream(); mCameraView.getBitmap().compress(Bitmap.CompressFormat.PNG, 100, bos); byte[] byteArray = bos.toByteArray(); intent.putExtra("RESULT_IMAGE", byteArray); startActivity(intent); } } }); //Corners View DisplayMetrics displaymetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); cornersView = (CornersView) findViewById(R.id.cornersView); shadow = (FrameLayout) findViewById(R.id.shadowLayout); cornersView.setShadow(shadow); //Starting the detection process startDetection(); //Microblink OCR try { mRecognizer = Recognizer.getSingletonInstance(); } catch (FeatureNotSupportedException e) { Toast.makeText(CameraActivity.this, "Feature not supported! Reason: " + e.getReason().getDescription(), Toast.LENGTH_LONG).show(); finish(); return; } try { // set license key mRecognizer.setLicenseKey(CameraActivity.this, "Y5352CQ5-A7KVPD26-UOAUEX4P-D2GQM63S-J6TCRGNH-T5WFKI24-QQZJRAXL-AT55KX4N"); } catch (InvalidLicenceKeyException exc) { finish(); return; } RecognitionSettings settings = new RecognitionSettings(); // setupSettingsArray method is described in chapter "Recognition settings and results") settings.setRecognizerSettingsArray(setupSettingsArray()); mRecognizer.initialize(CameraActivity.this, settings, new DirectApiErrorListener() { @Override public void onRecognizerError(Throwable t) { Toast.makeText(CameraActivity.this, "There was an error in initialization of Recognizer: " + t.getMessage(), Toast.LENGTH_SHORT) .show(); finish(); } }); }