List of usage examples for android.content Intent getFloatExtra
public float getFloatExtra(String name, float defaultValue)
From source file:Main.java
public static float getMeasuredFOV(Intent intent) { return intent.getFloatExtra(MEASURED_FOV_EXTRA, -1f); }
From source file:Main.java
public static float getReportedFOV(Intent intent) { return intent.getFloatExtra(REPORTED_FOV_EXTRA, -1f); }
From source file:Main.java
public static float getFloatExtra(Intent intent, String name, float defaultValue) { if (!hasIntent(intent) || !hasExtra(intent, name)) return defaultValue; return intent.getFloatExtra(name, defaultValue); }
From source file:com.doctoror.fuckoffmusicplayer.presentation.playback.PlaybackAndroidService.java
private void onActionSeek(final Intent intent) { if (intent.hasExtra(EXTRA_POSITION_PERCENT)) { onActionSeek(intent.getFloatExtra(EXTRA_POSITION_PERCENT, 0f)); }//from w w w . j a v a2s. co m }
From source file:com.softminds.matrixcalculator.OperationFragments.ScalerFragment.java
@Override public void onActivityResult(int req, int res, Intent data) { super.onActivityResult(req, res, data); if (res == 1054) { Intent intent = new Intent(getContext(), ShowResult.class); intent.putExtras(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(ClickPos) .getScalarMultiplied(data.getFloatExtra("MULTIPLIER_VAL", 0)).getDataBundled()); startActivity(intent);/* w w w. ja va2s. co m*/ } }
From source file:com.example.programming.proximityalerts.ProximityAlertService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Location bestLocation = null; latitude = intent.getDoubleExtra(LATITUDE_INTENT_KEY, Double.MIN_VALUE); longitude = intent.getDoubleExtra(LONGITUDE_INTENT_KEY, Double.MIN_VALUE); radius = intent.getFloatExtra(RADIUS_INTENT_KEY, Float.MIN_VALUE); for (String provider : locationManager.getProviders(false)) { if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return TODO; }/*w w w . j a va 2 s . c o m*/ Location location = locationManager.getLastKnownLocation(provider); if (bestLocation == null) { bestLocation = location; } else { if (location.getAccuracy() < bestLocation.getAccuracy()) { bestLocation = location; } } } if (bestLocation != null) { if (getDistance(bestLocation) <= radius) { inProximity = true; } else { inProximity = false; } } locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this); return START_STICKY; }
From source file:com.javadog.cgeowear.cgeoWearService.java
/** * Initializes the watch-side service's local variables from the intent passed to onStartCommand. * * @param startIntent The Intent passed to * {@link com.javadog.cgeowear.cgeoWearService#onStartCommand(android.content.Intent, int, int)} *///w w w. j a v a2s. com private void initLocalVars(final Intent startIntent) { cacheName = startIntent.getStringExtra(MessageDataset.KEY_CACHE_NAME); geocode = startIntent.getStringExtra(MessageDataset.KEY_GEOCODE); distance = startIntent.getFloatExtra(MessageDataset.KEY_DISTANCE, 0f); direction = startIntent.getFloatExtra(MessageDataset.KEY_DIRECTION, 0f); useWatchCompass = startIntent.getBooleanExtra(MessageDataset.KEY_WATCH_COMPASS, true); if (useWatchCompass) { Location cacheLoc = new Location("phoneApp"); cacheLoc.setLatitude(startIntent.getFloatExtra(MessageDataset.KEY_CACHE_LATITUDE, 0f)); cacheLoc.setLongitude(startIntent.getFloatExtra(MessageDataset.KEY_CACHE_LONGITUDE, 0f)); cacheLocation = cacheLoc; } }
From source file:com.javadog.cgeowear.cgeoWear.java
/** * Initializes the screen, whether the Activity was freshly-launched or onNewIntent was run. * * @param i The launch intent.//from ww w .jav a2s . c o m */ private void initScreen(Intent i) { String cacheName = i.getStringExtra(MessageDataSet.KEY_CACHE_NAME); String geocode = i.getStringExtra(MessageDataSet.KEY_GEOCODE); distance = i.getFloatExtra(MessageDataSet.KEY_DISTANCE, 0f); direction = i.getFloatExtra(MessageDataSet.KEY_DIRECTION, 0f); geocacheLocation = i.getParcelableExtra(MessageDataSet.KEY_CACHE_LOCATION); //Start listening for compass updates, if the user wants useWatchCompass = i.getBooleanExtra(MessageDataSet.KEY_WATCH_COMPASS, false); if (accelerometer != null && magnetometer != null) { sensorManager.unregisterListener(this, accelerometer); sensorManager.unregisterListener(this, magnetometer); } Log.d(DEBUG_TAG, useWatchCompass ? "Using watch compass." : "Using phone compass."); if (useWatchCompass) { sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); magnetometer = sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); sensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_NORMAL); sensorManager.registerListener(this, magnetometer, SensorManager.SENSOR_DELAY_NORMAL); } tv_cacheName.setText(cacheName); tv_geocode.setText(geocode); setDistanceFormatted(distance); rotateCompass(direction); }
From source file:com.ibm.pickmeup.activities.MapActivity.java
/** * Update map with the new coordinates for the driver * @param intent containing driver coordinates *//*from ww w .ja v a 2 s . c o m*/ private void updateMap(final Intent intent) { // not logging entry as it will flood the logs // getting driver LatLng values from the intent final LatLng driverLatLng = new LatLng(intent.getFloatExtra(Constants.LATITUDE, 0), intent.getFloatExtra(Constants.LONGITUDE, 0)); // create driver marker if it doesn't exist and move the camera accordingly if (driverMarker == null) { mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(driverLatLng, 10)); driverMarker = mMap.addMarker(new MarkerOptions().position(driverLatLng) .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_driver))); return; } // update driver location with LatLng driverLocation.setLatitude(driverLatLng.latitude); driverLocation.setLongitude(driverLatLng.longitude); // calculate current distance to the passenger float distance = passengerLocation.distanceTo(driverLocation) / 1000; // set the distance text distanceDetails.setText(String.format(getResources().getString(R.string.distance_with_value), distance)); // calculating ETA - we are assuming here that the car travels at 20mph to simplify the calculations calendar = Calendar.getInstance(); calendar.add(Calendar.MINUTE, Math.round(distance / 20 * 60)); // set AM/PM to a relevant value AM_PM = getString(R.string.am); if (calendar.get(Calendar.AM_PM) == 1) { AM_PM = getString(R.string.pm); } // format ETA string to HH:MM String eta = String.format(getResources().getString(R.string.eta_with_value), calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), AM_PM); // set the ETA text etaDetails.setText(eta); // as we are throttling updates to the coordinates, we might need to smooth out the moving // of the driver's marker. To do so we are going to draw temporary markers between the // previous and the current coordinates. We are going to use interpolation for this and // use handler/looper to set the marker's position // get hold of the handler final Handler handler = new Handler(); final long start = SystemClock.uptimeMillis(); // get map projection and the driver's starting point Projection proj = mMap.getProjection(); Point startPoint = proj.toScreenLocation(driverMarker.getPosition()); final LatLng startLatLng = proj.fromScreenLocation(startPoint); final long duration = 150; // create new Interpolator final Interpolator interpolator = new LinearInterpolator(); // post a Runnable to the handler handler.post(new Runnable() { @Override public void run() { // calculate how soon we need to redraw the marker long elapsed = SystemClock.uptimeMillis() - start; float t = interpolator.getInterpolation((float) elapsed / duration); double lng = t * intent.getFloatExtra(Constants.LONGITUDE, 0) + (1 - t) * startLatLng.longitude; double lat = t * intent.getFloatExtra(Constants.LATITUDE, 0) + (1 - t) * startLatLng.latitude; // set the driver's marker position driverMarker.setPosition(new LatLng(lat, lng)); if (t < 1.0) { handler.postDelayed(this, 10); } } }); }
From source file:com.tumanako.dash.DashMessages.java
@Override public void onReceive(Context context, Intent intent) { // Get the 'Action' from the intent: String action = intent.getAction(); // Get other data (if it was sent): Integer intData = null;//w ww . ja v a 2s .c o m Float floatData = null; String stringData = null; Bundle bundleData = null; if (intent.hasExtra(DASHMESSAGE_INT)) intData = intent.getIntExtra(DASHMESSAGE_INT, 0); if (intent.hasExtra(DASHMESSAGE_FLOAT)) floatData = intent.getFloatExtra(DASHMESSAGE_FLOAT, 0f); if (intent.hasExtra(DASHMESSAGE_STRING)) stringData = intent.getStringExtra(DASHMESSAGE_STRING); if (intent.hasExtra(DASHMESSAGE_DATA)) bundleData = intent.getBundleExtra(DASHMESSAGE_DATA); // --DEBUG!-- Log.i(com.tumanako.ui.UIActivity.APP_TAG, String.format( " DashMessages -> Msg Rec: %d", message) ); parent.messageReceived(action, intData, floatData, stringData, bundleData); }