Java Code Examples for android.content.Intent.getFloatExtra()

The following are Jave code examples for showing how to use getFloatExtra() of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Android-DFU-App   File: RSCActivity.java   View Source Code Vote up 7 votes
@Override
public void onReceive(final Context context, final Intent intent) {
	final String action = intent.getAction();

	if (RSCService.BROADCAST_RSC_MEASUREMENT.equals(action)) {
		final float speed = intent.getFloatExtra(RSCService.EXTRA_SPEED, 0.0f);
		final int cadence = intent.getIntExtra(RSCService.EXTRA_CADENCE, 0);
		final float totalDistance = intent.getFloatExtra(RSCService.EXTRA_TOTAL_DISTANCE, RSCManagerCallbacks.NOT_AVAILABLE);
		final int activity = intent.getIntExtra(RSCService.EXTRA_ACTIVITY, RSCManagerCallbacks.ACTIVITY_WALKING);
		// Update GUI
		onMeasurementReceived(speed, cadence, totalDistance, activity);
	} else if (RSCService.BROADCAST_STRIDES_UPDATE.equals(action)) {
		final int strides = intent.getIntExtra(RSCService.EXTRA_STRIDES, 0);
		final float distance = intent.getFloatExtra(RSCService.EXTRA_DISTANCE, 0);
		// Update GUI
		onStripesUpdate(distance, strides);
	}
}
 
Example 2
Project: Android-DFU-App   File: CSCActivity.java   View Source Code Vote up 7 votes
@Override
public void onReceive(final Context context, final Intent intent) {
	final String action = intent.getAction();

	if (CSCService.BROADCAST_WHEEL_DATA.equals(action)) {
		final float speed = intent.getFloatExtra(CSCService.EXTRA_SPEED, 0.0f); // [m/s]
		final float distance = intent.getFloatExtra(CSCService.EXTRA_DISTANCE, CSCManagerCallbacks.NOT_AVAILABLE);
		final float totalDistance = intent.getFloatExtra(CSCService.EXTRA_TOTAL_DISTANCE, CSCManagerCallbacks.NOT_AVAILABLE);
		// Update GUI
		onMeasurementReceived(speed, distance, totalDistance);
	} else if (CSCService.BROADCAST_CRANK_DATA.equals(action)) {
		final float ratio = intent.getFloatExtra(CSCService.EXTRA_GEAR_RATIO, 0);
		final int cadence = intent.getIntExtra(CSCService.EXTRA_CADENCE, 0);
		// Update GUI
		onGearRatioUpdate(ratio, cadence);
	}
}
 
Example 3
Project: Pocket-Plays-for-Twitch   File: MainActivity.java   View Source Code Vote up 7 votes
/**
 * Decides which animation to run based the intent that started the activity.
 */
public void initActivityAnimation() {
	Intent intent = this.getIntent();
	fromToolbarPosition = intent.getFloatExtra(
													  this.getResources().getString(R.string.decorative_toolbar_position_y), -1
	);

	fromMainToolbarPosition = intent.getFloatExtra(
													  this.getResources().getString(R.string.main_toolbar_position_y), -1
	);

	// If the position is equal to the default value,
	// then the intent was not put into from another MainActivity
	if(fromToolbarPosition != -1) {
		AnimationService.setActivityToolbarReset(mMainToolbar, mDecorativeToolbar, this, fromToolbarPosition, fromMainToolbarPosition);
	} else {
		AnimationService.setActivityToolbarCircularRevealAnimation(mDecorativeToolbar);
	}

	AnimationService.setActivityIconRevealAnimation(mCircleIconWrapper, mTitleView);
}
 
Example 4
Project: divertsy-client   File: MainActivity.java   View Source Code Vote up 6 votes
@Override
public void onReceive(Context context, Intent intent) {
    try {
        float fRemoteWeight = intent.getFloatExtra("floatScaleWeight", 0.0f);
        String sRemoteUnit = intent.getStringExtra("stringScaleUnit");

        // Assume KG as the default unit
        if ((sRemoteUnit == null ) || (sRemoteUnit.length() < 1)){
            sRemoteUnit = "KG";
        } else {
            sRemoteUnit = sRemoteUnit.toUpperCase();
        }
        Log.d(TAG, "RemoteScale Data Received: " + fRemoteWeight + " " + sRemoteUnit);

        // Update the on Screen Display
        mWeight.setText(Float.toString(fRemoteWeight));
        mWeightUnit.setText(sRemoteUnit);

        // Save the data so we can record it if the user taps a waste stream button
        ScaleMeasurement.Builder measurementBuilder = new ScaleMeasurement.Builder();
        measurementBuilder.rawScaleWeight(fRemoteWeight);
        measurementBuilder.scaleWeight(fRemoteWeight);
        measurementBuilder.units(sRemoteUnit);
        mLatestScaleMeasurement = measurementBuilder.build();

    }  catch (Exception e) {
        Log.e(TAG, "REMOTE DATA BROADCAST RECEIVER ERROR: " + e.getMessage());
    }
}
 
Example 5
Project: Tess-TwoDemo   File: CameraActivity.java   View Source Code Vote up 6 votes
private void setupViews(@NonNull Intent mIntent){
    leftRight = mIntent.getIntExtra(EasyCamera.EXTRA_MARGIN_BY_WIDTH,0);
    topBottom = mIntent.getIntExtra(EasyCamera.EXTRA_MARGIN_BY_HEIGHT,0);
    ratio = mIntent.getFloatExtra(EasyCamera.EXTRA_VIEW_RATIO, 1f);
    imageUri = mIntent.getParcelableExtra(EasyCamera.EXTRA_OUTPUT_URI);
    imagePath = FileUtils.getRealFilePath(this,imageUri);
}
 
Example 6
Project: cSun   File: UpdateScreenBrightness.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


    Handler handler = new Handler(new Handler.Callback() {
        @Override
        public boolean handleMessage(Message msg) {
            if(msg.what == DELAYED_MESSAGE) {
                UpdateScreenBrightness.this.finish();

            }
            return false;
        }

    });

    Intent brightnessIntent = this.getIntent();
    float brightness = brightnessIntent.getFloatExtra("brightness value", 0);
    WindowManager.LayoutParams lp = getWindow().getAttributes();
    lp.screenBrightness = brightness;
    getWindow().setAttributes(lp);

    Message message = handler.obtainMessage(DELAYED_MESSAGE);
    //this next line is very important, you need to finish your activity with slight delay
    handler.sendMessageDelayed(message,1);
}
 
Example 7
Project: Matrix-Calculator-for-Android   File: FillingMatrix.java   View Source Code Vote up 6 votes
@Override
protected void onActivityResult(int requestcode, int resultCode, Intent data) {
    super.onActivityResult(requestcode, resultCode, data);
    if (resultCode == RESULT) {
        if (data.getFloatExtra(CustomValueKey, 0) != 0)
            EmptyInput(data.getFloatExtra(CustomValueKey, 0));
    }
}
 
Example 8
Project: boohee_v5.6   File: UCropActivity.java   View Source Code Vote up 6 votes
private void setImageData(@NonNull Intent intent) {
    Uri inputUri = (Uri) intent.getParcelableExtra(UCrop.EXTRA_INPUT_URI);
    this.mOutputUri = (Uri) intent.getParcelableExtra(UCrop.EXTRA_OUTPUT_URI);
    processOptions(intent);
    if (inputUri == null || this.mOutputUri == null) {
        setResultException(new NullPointerException(getString(R.string
                .ucrop_error_input_data_is_absent)));
        finish();
    } else {
        try {
            this.mGestureCropImageView.setImageUri(inputUri);
        } catch (Exception e) {
            setResultException(e);
            finish();
        }
    }
    if (intent.getBooleanExtra(UCrop.EXTRA_ASPECT_RATIO_SET, false)) {
        this.mWrapperStateAspectRatio.setVisibility(8);
        float aspectRatioX = intent.getFloatExtra(UCrop.EXTRA_ASPECT_RATIO_X, 0.0f);
        float aspectRatioY = intent.getFloatExtra(UCrop.EXTRA_ASPECT_RATIO_Y, 0.0f);
        if (aspectRatioX <= 0.0f || aspectRatioY <= 0.0f) {
            this.mGestureCropImageView.setTargetAspectRatio(0.0f);
        } else {
            this.mGestureCropImageView.setTargetAspectRatio(aspectRatioX / aspectRatioY);
        }
    }
    if (intent.getBooleanExtra(UCrop.EXTRA_MAX_SIZE_SET, false)) {
        int maxSizeX = intent.getIntExtra(UCrop.EXTRA_MAX_SIZE_X, 0);
        int maxSizeY = intent.getIntExtra(UCrop.EXTRA_MAX_SIZE_Y, 0);
        if (maxSizeX <= 0 || maxSizeY <= 0) {
            Log.w(TAG, "EXTRA_MAX_SIZE_X and EXTRA_MAX_SIZE_Y must be greater than 0");
            return;
        }
        this.mGestureCropImageView.setMaxResultImageSizeX(maxSizeX);
        this.mGestureCropImageView.setMaxResultImageSizeY(maxSizeY);
    }
}
 
Example 9
Project: GravityBox   File: ModRinger.java   View Source Code Vote up 6 votes
@Override
public void onReceive(Context context, Intent intent) {
   if (intent.getAction().equals(IncreasingRingPreference.ACTION_INCREASING_RING_CHANGED) &&
           intent.getIntExtra(IncreasingRingPreference.EXTRA_STREAM_TYPE, -1) ==
               AudioManager.STREAM_RING) {
       mRingerConfig.enabled = intent.getBooleanExtra(
               IncreasingRingPreference.EXTRA_ENABLED, false);
       mRingerConfig.minVolume = intent.getFloatExtra(
               IncreasingRingPreference.EXTRA_MIN_VOLUME, 0.1f);
       mRingerConfig.rampUpDuration = intent.getIntExtra(
               IncreasingRingPreference.EXTRA_RAMP_UP_DURATION, 10);
       if (DEBUG) log(mRingerConfig.toString());
   }
}
 
Example 10
Project: AndroidOCRFforID   File: UCropActivity.java   View Source Code Vote up 5 votes
/**
 * This method extracts all data from the incoming intent and setups views properly.
 */
private void setImageData(@NonNull Intent intent) {
    Uri inputUri = intent.getParcelableExtra(UCrop.EXTRA_INPUT_URI);
    mOutputUri = intent.getParcelableExtra(UCrop.EXTRA_OUTPUT_URI);
    processOptions(intent);

    if (inputUri != null && mOutputUri != null) {
        try {
            mGestureCropImageView.setImageUri(inputUri, mOutputUri);
        } catch (Exception e) {
            setResultException(e);
            finish();
        }
    } else {
        setResultException(new NullPointerException(getString(R.string.ucrop_error_input_data_is_absent)));
        finish();
    }

    if (intent.getBooleanExtra(UCrop.EXTRA_ASPECT_RATIO_SET, false)) {
        if (mShowBottomControls) {
            mWrapperStateAspectRatio.setVisibility(View.GONE);
        }

        float aspectRatioX = intent.getFloatExtra(UCrop.EXTRA_ASPECT_RATIO_X, 0);
        float aspectRatioY = intent.getFloatExtra(UCrop.EXTRA_ASPECT_RATIO_Y, 0);

        if (aspectRatioX > 0 && aspectRatioY > 0) {
            mGestureCropImageView.setTargetAspectRatio(aspectRatioX / aspectRatioY);
        } else {
            mGestureCropImageView.setTargetAspectRatio(CropImageView.SOURCE_IMAGE_ASPECT_RATIO);
        }
    }

    if (intent.getBooleanExtra(UCrop.EXTRA_MAX_SIZE_SET, false)) {
        int maxSizeX = intent.getIntExtra(UCrop.EXTRA_MAX_SIZE_X, 0);
        int maxSizeY = intent.getIntExtra(UCrop.EXTRA_MAX_SIZE_Y, 0);

        if (maxSizeX > 0 && maxSizeY > 0) {
            mGestureCropImageView.setMaxResultImageSizeX(maxSizeX);
            mGestureCropImageView.setMaxResultImageSizeY(maxSizeY);
        } else {
            Log.w(TAG, "EXTRA_MAX_SIZE_X and EXTRA_MAX_SIZE_Y must be greater than 0");
        }
    }
}
 
Example 11
Project: VanGogh   File: VanCropActivity.java   View Source Code Vote up 5 votes
private void setImageData(Intent intent) {
    Uri inputUri = intent.getParcelableExtra(UCrop.EXTRA_INPUT_URI);
    mOutputUri = intent.getParcelableExtra(UCrop.EXTRA_OUTPUT_URI);

    if (inputUri != null && mOutputUri != null) {
        try {
            mGestureCropImageView.setImageUri(inputUri);
        } catch (Exception e) {
            setResultException(e);
            finish();
        }
    } else {
        setResultException(new NullPointerException("Both input and output Uri must be specified"));
        finish();
    }

    // 设置裁剪宽高比
    if (intent.getBooleanExtra(UCrop.EXTRA_ASPECT_RATIO_SET, false)) {
        float aspectRatioX = intent.getFloatExtra(UCrop.EXTRA_ASPECT_RATIO_X, 0);
        float aspectRatioY = intent.getFloatExtra(UCrop.EXTRA_ASPECT_RATIO_Y, 0);

        if (aspectRatioX > 0 && aspectRatioY > 0) {
            mGestureCropImageView.setTargetAspectRatio(aspectRatioX / aspectRatioY);
        } else {
            mGestureCropImageView.setTargetAspectRatio(CropImageView.SOURCE_IMAGE_ASPECT_RATIO);
        }
    }

    // 设置裁剪的最大宽高
    if (intent.getBooleanExtra(UCrop.EXTRA_MAX_SIZE_SET, false)) {
        int maxSizeX = intent.getIntExtra(UCrop.EXTRA_MAX_SIZE_X, 0);
        int maxSizeY = intent.getIntExtra(UCrop.EXTRA_MAX_SIZE_Y, 0);

        if (maxSizeX > 0 && maxSizeY > 0) {
            mGestureCropImageView.setMaxResultImageSizeX(maxSizeX);
            mGestureCropImageView.setMaxResultImageSizeY(maxSizeY);
        } else {
            Log.w(TAG, "EXTRA_MAX_SIZE_X and EXTRA_MAX_SIZE_Y must be greater than 0");
        }
    }
}