この関数は 0.0 を返しますが、値はすべて float であり、共有設定から正しく取得されます。エラーは何ですか?
float BMR(){
SharedPreferences customSharedPreference = getSharedPreferences(
"myCustomSharedPrefs", Activity.MODE_PRIVATE);
String Weight =customSharedPreference.getString("weightpref", null);
float weight = Float.valueOf(Weight);
String Height = customSharedPreference.getString("heightpref",null);
float height = Float.valueOf(Height);
String Age = customSharedPreference.getString("agepref", null);
float age = Float.valueOf(Age);
int gender = customSharedPreference.getInt("genderpref", 0);
Toast.makeText(StatsActivity.this, Age, Toast.LENGTH_LONG).show();
if ( gender == 0){
bmr = (float) (10.0 *weight + 6.25 * height - 5.0 * age + 5.0);
}
if(gender == 1){
bmr = (float) (10.0 * weight + 6.25 * height - 5.0 * age- 161.0);
}
String bmrtest = String.valueOf(bmr);
Toast.makeText(StatsActivity.this, "bmr is "+bmrtest, Toast.LENGTH_LONG).show();
return bmr;
}