本文整理汇总了Java中android.content.Intent.getFloatExtra方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.getFloatExtra方法的具体用法?Java Intent.getFloatExtra怎么用?Java Intent.getFloatExtra使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.Intent
的用法示例。
在下文中一共展示了Intent.getFloatExtra方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@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);
}
}
示例2: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@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);
}
}
示例3: initActivityAnimation
import android.content.Intent; //导入方法依赖的package包/类
/**
* 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);
}
示例4: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@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());
}
}
示例5: setupViews
import android.content.Intent; //导入方法依赖的package包/类
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);
}
示例6: onCreate
import android.content.Intent; //导入方法依赖的package包/类
@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);
}
示例7: onActivityResult
import android.content.Intent; //导入方法依赖的package包/类
@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));
}
}
示例8: setImageData
import android.content.Intent; //导入方法依赖的package包/类
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);
}
}
示例9: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@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());
}
}
示例10: setImageData
import android.content.Intent; //导入方法依赖的package包/类
/**
* 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");
}
}
}
示例11: setImageData
import android.content.Intent; //导入方法依赖的package包/类
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");
}
}
}