List of usage examples for android.content Context SENSOR_SERVICE
String SENSOR_SERVICE
To view the source code for android.content Context SENSOR_SERVICE.
Click Source Link
From source file:gov.nasa.arc.geocam.geocam.CameraActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Window and view properties requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.camera);//from www . j a v a 2 s. co m // Location mLocationReceiver = new LocationReceiver(); mLocationFormatter.setMaximumFractionDigits(6); mLatText = (TextView) findViewById(R.id.camera_textview_lat); mLonText = (TextView) findViewById(R.id.camera_textview_lon); // Orientation mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); // Camera mCameraPreview = (SurfaceView) findViewById(R.id.camera_surfaceview); mHolder = mCameraPreview.getHolder(); mHolder.addCallback(this); mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); // UI elements mFocusRect = (ImageView) findViewById(R.id.camera_focus_imageview); mFocusRect.setImageDrawable(getResources().getDrawable(R.drawable.frame_unfocused_64x48)); final ImageButton shutterButton = (ImageButton) findViewById(R.id.camera_shutter_button); shutterButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (!mPictureTaken) { mPictureTaken = true; if (!mLensIsFocused) { mFocusRect.setImageDrawable(getResources().getDrawable(R.drawable.frame_unfocused_64x48)); mLensIsFocused = true; CameraActivity.this.focusLens(true); } else { CameraActivity.this.takePicture(); } } } }); mForeground = new ForegroundTracker(this); }
From source file:co.taqat.call.CallActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); instance = this; if (getResources().getBoolean(R.bool.orientation_portrait_only)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); }//from w w w . j a va2 s.c o m getWindow().addFlags( WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); setContentView(R.layout.call); isTransferAllowed = getApplicationContext().getResources().getBoolean(R.bool.allow_transfers); if (!BluetoothManager.getInstance().isBluetoothHeadsetAvailable()) { BluetoothManager.getInstance().initBluetooth(); } cameraNumber = AndroidCameraConfiguration.retrieveCameras().length; try { // Yeah, this is hidden field. field = PowerManager.class.getClass().getField("PROXIMITY_SCREEN_OFF_WAKE_LOCK").getInt(null); } catch (Throwable ignored) { } powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); wakeLock = powerManager.newWakeLock(field, getLocalClassName()); mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); mProximity = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY); mListener = new LinphoneCoreListenerBase() { @Override public void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) { displayMissedChats(); } @Override public void callState(LinphoneCore lc, final LinphoneCall call, LinphoneCall.State state, String message) { if (LinphoneManager.getLc().getCallsNb() == 0) { finish(); return; } if (state == State.IncomingReceived) { startIncomingCallActivity(); return; } else if (state == State.Paused || state == State.PausedByRemote || state == State.Pausing) { if (LinphoneManager.getLc().getCurrentCall() != null) { enabledVideoButton(false); } if (isVideoEnabled(call)) { showAudioView(); } } else if (state == State.Resuming) { if (LinphonePreferences.instance().isVideoEnabled()) { status.refreshStatusItems(call, isVideoEnabled(call)); if (call.getCurrentParamsCopy().getVideoEnabled()) { showVideoView(); } } if (LinphoneManager.getLc().getCurrentCall() != null) { enabledVideoButton(true); } } else if (state == State.StreamsRunning) { switchVideo(isVideoEnabled(call)); enableAndRefreshInCallActions(); if (status != null) { videoProgress.setVisibility(View.GONE); status.refreshStatusItems(call, isVideoEnabled(call)); } } else if (state == State.CallUpdatedByRemote) { // If the correspondent proposes video while audio call boolean videoEnabled = LinphonePreferences.instance().isVideoEnabled(); if (!videoEnabled) { acceptCallUpdate(false); } boolean remoteVideo = call.getRemoteParams().getVideoEnabled(); boolean localVideo = call.getCurrentParamsCopy().getVideoEnabled(); boolean autoAcceptCameraPolicy = true;//LinphonePreferences.instance().shouldAutomaticallyAcceptVideoRequests(); if (remoteVideo && !localVideo && !autoAcceptCameraPolicy && !LinphoneManager.getLc().isInConference()) { showAcceptCallUpdateDialog(); timer = new CountDownTimer(SECONDS_BEFORE_DENYING_CALL_UPDATE, 1000) { public void onTick(long millisUntilFinished) { } public void onFinish() { //TODO dismiss dialog acceptCallUpdate(false); } }.start(); /*showAcceptCallUpdateDialog(); timer = new CountDownTimer(SECONDS_BEFORE_DENYING_CALL_UPDATE, 1000) { public void onTick(long millisUntilFinished) { } public void onFinish() { //TODO dismiss dialog } }.start();*/ } // else if (remoteVideo && !LinphoneManager.getLc().isInConference() && autoAcceptCameraPolicy) { // mHandler.post(new Runnable() { // @Override // public void run() { // acceptCallUpdate(true); // } // }); // } } refreshIncallUi(); transfer.setEnabled(LinphoneManager.getLc().getCurrentCall() != null); } @Override public void callEncryptionChanged(LinphoneCore lc, final LinphoneCall call, boolean encrypted, String authenticationToken) { if (status != null) { if (call.getCurrentParamsCopy().getMediaEncryption().equals(LinphoneCore.MediaEncryption.ZRTP) && !call.isAuthenticationTokenVerified()) { status.showZRTPDialog(call); } status.refreshStatusItems(call, call.getCurrentParamsCopy().getVideoEnabled()); } } }; if (findViewById(R.id.fragmentContainer) != null) { initUI(); if (LinphoneManager.getLc().getCallsNb() > 0) { LinphoneCall call = LinphoneManager.getLc().getCalls()[0]; if (LinphoneUtils.isCallEstablished(call)) { enableAndRefreshInCallActions(); } } if (savedInstanceState != null) { // Fragment already created, no need to create it again (else it will generate a memory leak with duplicated fragments) isSpeakerEnabled = savedInstanceState.getBoolean("Speaker"); isMicMuted = savedInstanceState.getBoolean("Mic"); isVideoCallPaused = savedInstanceState.getBoolean("VideoCallPaused"); refreshInCallActions(); return; } else { isSpeakerEnabled = LinphoneManager.getLc().isSpeakerEnabled(); isMicMuted = LinphoneManager.getLc().isMicMuted(); } Fragment callFragment; if (isVideoEnabled(LinphoneManager.getLc().getCurrentCall())) { callFragment = new CallVideoFragment(); videoCallFragment = (CallVideoFragment) callFragment; displayVideoCall(false); LinphoneManager.getInstance().routeAudioToSpeaker(); isSpeakerEnabled = true; } else { callFragment = new CallAudioFragment(); audioCallFragment = (CallAudioFragment) callFragment; } if (BluetoothManager.getInstance().isBluetoothHeadsetAvailable()) { BluetoothManager.getInstance().routeAudioToBluetooth(); } callFragment.setArguments(getIntent().getExtras()); getFragmentManager().beginTransaction().add(R.id.fragmentContainer, callFragment) .commitAllowingStateLoss(); } }
From source file:com.sinelead.car.club.map.AMapEx.java
private void setUpSensor() { mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); mOrientationSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION); angle = 0;/*from ww w .j a v a 2 s .c om*/ setRotateWithSensor(true); }
From source file:com.achep.acdisplay.services.activemode.ActiveModeService.java
@Override public void onStart(Object... objects) { if (Build.DEBUG) Log.d(TAG, "Starting listening to sensors."); Context context = getContext(); SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); for (ActiveModeSensor sensor : mSensors) { sensor.registerCallback(this); sensor.onAttached(sensorManager, context); }/*from w ww. j av a 2 s . com*/ pingConsumingSensorsInternal(); }
From source file:org.chromium.latency.walt.AccelerometerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { logger = SimpleLogger.getInstance(getContext()); waltDevice = WaltDevice.getInstance(getContext()); // Inflate the layout for this fragment final View view = inflater.inflate(R.layout.fragment_accelerometer, container, false); logTextView = (TextView) view.findViewById(R.id.txt_log); startButton = view.findViewById(R.id.button_start); latencyChart = (ScatterChart) view.findViewById(R.id.latency_chart); latencyChartLayout = view.findViewById(R.id.latency_chart_layout); logTextView.setMovementMethod(new ScrollingMovementMethod()); view.findViewById(R.id.button_close_chart).setOnClickListener(this); sensorManager = (SensorManager) getContext().getSystemService(Context.SENSOR_SERVICE); accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); if (accelerometer == null) { logger.log("ERROR! Accelerometer sensor not found"); }/*w ww.j av a 2 s. c o m*/ return view; }
From source file:com.example.hciproject.CameraActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_camera); thisActivity = this; shopId = this.getIntent().getIntExtra("id", 0); url = "http://api.skroutz.gr/shops/" + shopId + "/locations"; new GETLATLONG().execute(url); if (null == savedInstanceState) { fragment = Camera2VideoFragment.newInstance(); getFragmentManager().beginTransaction().replace(R.id.container, fragment).commit(); }/* ww w. ja v a2s . c o m*/ mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); gyroSensor = mSensorManager.getSensorList(TYPE_ACCELEROMETER).get(0); magnetSensor = mSensorManager.getSensorList(TYPE_MAGNETIC_FIELD).get(0); Log.d("SENSOR", magnetSensor == null ? "NO MAGNETOMETER" : "MAGNETOMETER SUCCESS"); Log.d("SENSOR", gyroSensor == null ? "NO ACCELEROMETER" : "ACCELEROMETER SUCCESS"); mSensorManager.registerListener(gyroListener, gyroSensor, SENSOR_DELAY_UI); mSensorManager.registerListener(gyroListener, magnetSensor, SENSOR_DELAY_UI); int permissionCheck = ContextCompat.checkSelfPermission(thisActivity, Manifest.permission.ACCESS_FINE_LOCATION); if (permissionCheck != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity, Manifest.permission.ACCESS_FINE_LOCATION)) { // Show an explanation to the user *asynchronously* -- don't block // this thread waiting for the user's response! After the user // sees the explanation, try again to request the permission. } else { // No explanation needed, we can request the permission. ActivityCompat.requestPermissions(thisActivity, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, 100); // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an // app-defined int constant. The callback method gets the // result of the request. } } else { requestLocation(); } }
From source file:io.v.moments.ux.MainActivity.java
private void initializeShakeDetector() { mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); }
From source file:com.android.gpstest.GpsTestActivity.java
/** Called when the activity is first created. */ @Override//from w w w . ja va 2 s.c o m public void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); super.onCreate(savedInstanceState); sInstance = this; // Set the default values from the XML file if this is the first // execution of the app PreferenceManager.setDefaultValues(this, R.xml.preferences, false); mService = (LocationManager) getSystemService(Context.LOCATION_SERVICE); if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Permission Denied Toast.makeText(this, getString(R.string.permission_denied), Toast.LENGTH_SHORT).show(); finish(); return; } else { mProvider = mService.getProvider(LocationManager.GPS_PROVIDER); if (mProvider == null) { Log.e(TAG, "Unable to get GPS_PROVIDER"); Toast.makeText(this, getString(R.string.gps_not_supported), Toast.LENGTH_SHORT).show(); finish(); return; } } mService.addGpsStatusListener(this); mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); // If we have a large screen, show all the fragments in one layout if (GpsTestUtil.isLargeScreen(this)) { setContentView(R.layout.activity_main_large_screen); mIsLargeScreen = true; } else { setContentView(R.layout.activity_main); } initActionBar(savedInstanceState); SharedPreferences settings = Application.getPrefs(); double tempMinTime = Double.valueOf(settings.getString(getString(R.string.pref_key_gps_min_time), getString(R.string.pref_gps_min_time_default_sec))); minTime = (long) (tempMinTime * SECONDS_TO_MILLISECONDS); minDistance = Float.valueOf(settings.getString(getString(R.string.pref_key_gps_min_distance), getString(R.string.pref_gps_min_distance_default_meters))); if (settings.getBoolean(getString(R.string.pref_key_auto_start_gps), true)) { gpsStart(); } }
From source file:radu.pidroid.Controller.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.controller); ActionBar actionBar = getActionBar(); actionBar.hide();//from ww w . j a v a2 s.c o m speechButton = (ImageView) findViewById(R.id.speechButton); speechButton.setOnClickListener(new ImageView.OnClickListener() { public void onClick(View view) { startVoiceRecognition(); } // onClick }); touchControlsLayout = (RelativeLayout) findViewById(R.id.TouchControlsLayout); forwardsPowerImageView = (ImageView) findViewById(R.id.forwardsPowerImageView); forwardsPowerImageView.setOnTouchListener(this); backwardsPowerImageView = (ImageView) findViewById(R.id.backwardsPowerImageView); backwardsPowerImageView.setOnTouchListener(this); forwardsPowerProgressBar = (ProgressBar) findViewById(R.id.forwardsPowerProgressBar); backwardsPowerProgressBar = (ProgressBar) findViewById(R.id.backwardsPowerProgressBar); sliderControlsLayout = (RelativeLayout) findViewById(R.id.SliderControlsLayout); forwardsPowerSeekBar = (SeekBar) findViewById(R.id.forwardsPowerSeekBar); forwardsPowerSeekBar.setOnSeekBarChangeListener(this); backwardsPowerSeekBar = (SeekBar) findViewById(R.id.backwardsPowerSeekBar); backwardsPowerSeekBar.setOnSeekBarChangeListener(this); joystickControlsLayout = (RelativeLayout) findViewById(R.id.JoystickControlsLayout); largeCameraJoystickView = (JoystickView) findViewById(R.id.largeCameraJoystickView); largeCameraJoystickView.setMoveListener(this); directionJoystickView = (JoystickView) findViewById(R.id.directionJoystickView); directionJoystickView.setMoveListener(this); videoFeedMjpegView = (MjpegView) findViewById(R.id.videoFeedSurfaceView); hudImageView = (ImageView) findViewById(R.id.hudImageView); levelIndicatorImageView = (ImageView) findViewById(R.id.levelIndicatorImageView); mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); mGeomagnetic = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); smallCameraJoystickView = (JoystickView) findViewById(R.id.cameraJoystickView); smallCameraJoystickView.setMoveListener(this); smallCameraJoystickView.setTag("smallCamera"); spinControlOn = false; toggleSpinImageView = (ImageView) findViewById(R.id.toggleSpinImageView); toggleSpinImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // if spinControl is ON then tiltControls are OFF and vice versa spinControlOn = !spinControlOn; tiltControlsOn = !tiltControlsOn; if (spinControlOn) toggleSpinImageView.setImageResource(R.drawable.spin_button_down); else toggleSpinImageView.setImageResource(R.drawable.spin_button_up); // Let PiDroid know whether to spin mMessenger.toggleSpin(spinControlOn); } // onClick }); // Get the message from the intent Intent intent = getIntent(); serverIP = intent.getStringExtra(Main.EXTRA_SERVERIP); serverPort = intent.getIntExtra(Main.EXTRA_SERVERPORT, 8090); mMessenger = new Messenger(this, serverIP, serverPort); mRecogniser = new CommandRecogniser(this, mMessenger, videoFeedMjpegView); if (Main.detailsCheckBox.isChecked()) loadPreferences(); else clearPreferences(); setupNavigationDrawer(); setupVideoFeed(); if (tutorialsOn) new ControllerTutorial(this).start(); }
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);// w w w. j a v a2s.c o 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(); } }); }