本文整理了Java中android.content.Intent.getFloatExtra()
方法的一些代码示例,展示了Intent.getFloatExtra()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Intent.getFloatExtra()
方法的具体详情如下:
包路径:android.content.Intent
类名称:Intent
方法名:getFloatExtra
暂无
代码示例来源:origin: robolectric/robolectric
@Test
public void testFloatExtra() throws Exception {
Intent intent = new Intent();
assertSame(intent, intent.putExtra("foo", 2f));
assertThat(intent.getExtras().get("foo")).isEqualTo(2f);
assertThat(intent.getFloatExtra("foo", -1)).isEqualTo(2f);
}
代码示例来源:origin: TeamNewPipe/NewPipe
public void handleIntent(Intent intent) {
if (DEBUG) Log.d(TAG, "handleIntent() called with: intent = [" + intent + "]");
if (intent == null) return;
// Resolve play queue
if (!intent.hasExtra(PLAY_QUEUE_KEY)) return;
final String intentCacheKey = intent.getStringExtra(PLAY_QUEUE_KEY);
final PlayQueue queue = SerializedCache.getInstance().take(intentCacheKey, PlayQueue.class);
if (queue == null) return;
// Resolve append intents
if (intent.getBooleanExtra(APPEND_ONLY, false) && playQueue != null) {
int sizeBeforeAppend = playQueue.size();
playQueue.append(queue.getStreams());
if ((intent.getBooleanExtra(SELECT_ON_APPEND, false) ||
getCurrentState() == STATE_COMPLETED) &&
queue.getStreams().size() > 0) {
playQueue.setIndex(sizeBeforeAppend);
}
return;
}
final int repeatMode = intent.getIntExtra(REPEAT_MODE, getRepeatMode());
final float playbackSpeed = intent.getFloatExtra(PLAYBACK_SPEED, getPlaybackSpeed());
final float playbackPitch = intent.getFloatExtra(PLAYBACK_PITCH, getPlaybackPitch());
final boolean playbackSkipSilence = intent.getBooleanExtra(PLAYBACK_SKIP_SILENCE,
getPlaybackSkipSilence());
// Good to go...
initPlayback(queue, repeatMode, playbackSpeed, playbackPitch, playbackSkipSilence,
/*playOnInit=*/true);
}
代码示例来源:origin: Yalantis/uCrop
mGestureCropImageView.setMaxScaleMultiplier(intent.getFloatExtra(UCrop.Options.EXTRA_MAX_SCALE_MULTIPLIER, CropImageView.DEFAULT_MAX_SCALE_MULTIPLIER));
mGestureCropImageView.setImageToWrapCropBoundsAnimDuration(intent.getIntExtra(UCrop.Options.EXTRA_IMAGE_TO_CROP_BOUNDS_ANIM_DURATION, CropImageView.DEFAULT_IMAGE_TO_CROP_BOUNDS_ANIM_DURATION));
float aspectRatioX = intent.getFloatExtra(UCrop.EXTRA_ASPECT_RATIO_X, 0);
float aspectRatioY = intent.getFloatExtra(UCrop.EXTRA_ASPECT_RATIO_Y, 0);
代码示例来源:origin: WangDaYeeeeee/GeometricWeather
private void readData(Intent intent) {
if (intent != null) {
if (intent.getBooleanExtra(KEY_UPDATE_SETTINGS, false)) {
pollingRate = intent.getFloatExtra(KEY_POLLING_RATE, 1.5f);
todayForecastTime = intent.getStringExtra(KEY_TODAY_FORECAST_TIME);
tomorrowForecastTime = intent.getStringExtra(KEY_TOMORROW_FORECAST_TIME);
}
if (!intent.getBooleanExtra(KEY_UPDATE_RESULT, true)) {
lastUpdateNormalViewTime = System.currentTimeMillis() - getPollingInterval() + 15 * 60 * 1000;
}
}
}
代码示例来源:origin: animalize/QuanTangshi
@Override
protected void onActivityResult(int requestCode,
int resultCode,
Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == STUDY_REQ_CODE && resultCode == RESULT_FIRST_USER) {
studyPosi = data.getFloatExtra("posi", 0);
studyTags = data.getStringArrayExtra("tags");
}
}
代码示例来源:origin: fengzhizi715/Tess-TwoDemo
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);
}
代码示例来源:origin: lizhifeng-sky/VideoEdit
@Override
public float videoPreferredAspect() {
return getIntent().getFloatExtra(CameraIntentKey.VIDEO_PREFERRED_ASPECT, 4f / 3f);
}
代码示例来源:origin: JackWHLiu/jackknife
public static float getFloatExtra(Intent intent, String name, float defaultValue) {
if (intent != null || !hasExtra(intent, name)) return defaultValue;
return intent.getFloatExtra(name, defaultValue);
}
代码示例来源:origin: markusfisch/ShaderEditor
private boolean setShaderFromIntent(Intent intent) {
String fragmentShader;
if (intent == null ||
shaderView == null ||
(fragmentShader = intent.getStringExtra(
FRAGMENT_SHADER)) == null) {
return false;
}
shaderView.setFragmentShader(
fragmentShader,
intent.getFloatExtra(QUALITY, 1f));
return true;
}
}
代码示例来源:origin: NordicSemiconductor/Android-nRF-Toolbox
@Override
public void onReceive(final Context context, final Intent intent) {
final String action = intent.getAction();
if (HTSService.BROADCAST_HTS_MEASUREMENT.equals(action)) {
final float value = intent.getFloatExtra(HTSService.EXTRA_TEMPERATURE, 0.0f);
// Update GUI
onTemperatureMeasurementReceived(value);
} else if (HTSService.BROADCAST_BATTERY_LEVEL.equals(action)) {
final int batteryLevel = intent.getIntExtra(HTSService.EXTRA_BATTERY_LEVEL, 0);
// Update GUI
onBatteryLevelChanged(batteryLevel);
}
}
};
代码示例来源:origin: vbier/habpanelviewer
public void onReceive(Context ctx, Intent i) {
if (ACTION_KEEP_SCREEN_ON.equals(i.getAction())) {
final boolean keepOn = i.getBooleanExtra(FLAG_KEEP_SCREEN_ON, false);
runOnUiThread(() -> {
Log.d(TAG, "onReceive: set keep on: " + keepOn);
setKeepScreenOn(keepOn);
});
} else if (ACTION_SET_BRIGHTNESS.equals(i.getAction())) {
final float brightness = i.getFloatExtra(FLAG_BRIGHTNESS, 1.0f);
runOnUiThread(() -> {
Log.d(TAG, "onReceive: set brightness: " + brightness);
setBrightness(brightness);
});
}
}
};
代码示例来源:origin: NordicSemiconductor/Android-nRF-Toolbox
@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 long totalDistance = intent.getLongExtra(RSCService.EXTRA_TOTAL_DISTANCE, -1);
final boolean running = intent.getBooleanExtra(RSCService.EXTRA_ACTIVITY, false);
// Update GUI
onMeasurementReceived(speed, cadence, totalDistance, running);
} else if (RSCService.BROADCAST_STRIDES_UPDATE.equals(action)) {
final int strides = intent.getIntExtra(RSCService.EXTRA_STRIDES, 0);
final long distance = intent.getLongExtra(RSCService.EXTRA_DISTANCE, -1);
// Update GUI
onStripesUpdate(distance, strides);
}
}
};
代码示例来源:origin: xiaolongonly/Ticket-Analysis
public static float getFloatExtra(Intent intent, String name, float defaultValue) {
if (!hasIntent(intent) || !hasExtra(intent, name)) return defaultValue;
return intent.getFloatExtra(name, defaultValue);
}
代码示例来源:origin: renyuneyun/Easer
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Handler handler = new StopHandler(this);
Intent intent = this.getIntent();
float brightness = intent.getFloatExtra(EXTRA_BRIGHTNESS, 0);
WindowManager.LayoutParams params = getWindow().getAttributes();
params.screenBrightness = brightness;
getWindow().setAttributes(params);
Message message = handler.obtainMessage(StopHandler.DELAYED_MESSAGE);
handler.sendMessageDelayed(message,1000);
}
代码示例来源:origin: andmizi/MobikeTags
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == 110 && data != null){
float density = data.getFloatExtra("density",-1);
float friction = data.getFloatExtra("friction",-1);
float restitution = data.getFloatExtra("restitution",-1);
float ratio = data.getFloatExtra("ratio",-1);
mobikeView.getmMobike().setDensity(density);
mobikeView.getmMobike().setFriction(friction);
mobikeView.getmMobike().setRestitution(restitution);
mobikeView.getmMobike().setRatio(ratio);
mobikeView.getmMobike().update();
}
}
代码示例来源:origin: Meituan-Dianping/Shield
public static float getFloatParam(String name, float defaultValue, Fragment fragment) {
if (fragment.getArguments() != null && fragment.getArguments().containsKey(name)) {
return fragment.getArguments().getFloat(name);
}
Intent i = fragment.getActivity().getIntent();
try {
Uri uri = i.getData();
if (uri != null) {
String val = uri.getQueryParameter(name);
if (!TextUtils.isEmpty(val))
return Float.parseFloat(val);
}
} catch (Exception e) {
e.printStackTrace();
}
return i.getFloatExtra(name, defaultValue);
}
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
private void parseBatteryData(final Intent intent, final LinkingBeacon beacon) {
if (intent.getExtras().containsKey(LinkingBeaconUtil.LOW_BATTERY) ||
intent.getExtras().containsKey(LinkingBeaconUtil.BATTERY_LEVEL)) {
BatteryData battery = beacon.getBatteryData();
if (battery == null) {
battery = new BatteryData();
beacon.setBatteryData(battery);
}
long timeStamp = intent.getLongExtra(LinkingBeaconUtil.TIME_STAMP, 0);
boolean lowBattery = intent.getBooleanExtra(LinkingBeaconUtil.LOW_BATTERY, false);
float level = intent.getFloatExtra(LinkingBeaconUtil.BATTERY_LEVEL, 0);
battery.setTimeStamp(timeStamp);
battery.setLowBatteryFlag(lowBattery);
battery.setLevel(level);
mDBAdapter.insertBattery(beacon, battery);
notifyBeaconBatteryEventListener(beacon, battery);
}
}
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
private void parseHumidityData(final Intent intent, final LinkingBeacon beacon) {
if (intent.getExtras().containsKey(LinkingBeaconUtil.HUMIDITY)) {
HumidityData humidity = beacon.getHumidityData();
if (humidity == null) {
humidity = new HumidityData();
beacon.setHumidityData(humidity);
}
long timeStamp = intent.getLongExtra(LinkingBeaconUtil.TIME_STAMP, 0);
float value = intent.getFloatExtra(LinkingBeaconUtil.HUMIDITY, 0);
humidity.setTimeStamp(timeStamp);
humidity.setValue(value);
mDBAdapter.insertHumidity(beacon, humidity);
notifyBeaconHumidityEventListener(beacon, humidity);
}
}
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
private void parseTemperatureData(final Intent intent, final LinkingBeacon beacon) {
if (intent.getExtras().containsKey(LinkingBeaconUtil.TEMPERATURE)) {
TemperatureData temp = beacon.getTemperatureData();
if (temp == null) {
temp = new TemperatureData();
beacon.setTemperatureData(temp);
}
long timeStamp = intent.getLongExtra(LinkingBeaconUtil.TIME_STAMP, 0);
float value = intent.getFloatExtra(LinkingBeaconUtil.TEMPERATURE, 0);
temp.setTimeStamp(timeStamp);
temp.setValue(value);
mDBAdapter.insertTemperature(beacon, temp);
notifyBeaconTemperatureEventListener(beacon, temp);
}
}
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
private void parseAtmosphericPressureData(final Intent intent, final LinkingBeacon beacon) {
if (intent.getExtras().containsKey(LinkingBeaconUtil.ATMOSPHERIC_PRESSURE)) {
AtmosphericPressureData atm = beacon.getAtmosphericPressureData();
if (atm == null) {
atm = new AtmosphericPressureData();
beacon.setAtmosphericPressureData(atm);
}
long timeStamp = intent.getLongExtra(LinkingBeaconUtil.TIME_STAMP, 0);
float value = intent.getFloatExtra(LinkingBeaconUtil.ATMOSPHERIC_PRESSURE, 0);
atm.setTimeStamp(timeStamp);
atm.setValue(value);
mDBAdapter.insertAtmosphericPressure(beacon, atm);
notifyBeaconAtmosphericPressureEventListener(beacon, atm);
}
}
内容来源于网络,如有侵权,请联系作者删除!