Hello guys, as I said the activity is crashing. So I'm passing some values from an activity to another using multiple intent.putExtra() to another screen. I can't find why I does work. All helps are welcome.
Bellow is the code where I recover the putExtra()
Bellow is the code where I recover the putExtra()
Java:
public class StatusActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_status);
TextView pHLevel = (TextView)findViewById(R.id.phLevel);
TextView organicCLevel = (TextView)findViewById(R.id.organicCLevel);
TextView nitrogenLevel = (TextView)findViewById(R.id.nitrogenlevel);
TextView phosphorusLevel = (TextView)findViewById(R.id.phosphorusLevel);
TextView potassiumLevel = (TextView)findViewById(R.id.potassiumLevel);
TextView zincLevel = (TextView)findViewById(R.id.zincLevel);
TextView temperatureLevel = (TextView)findViewById(R.id.temparatureLevel);
TextView date1 = (TextView)findViewById(R.id.date);
String tempMessage="";
String pHMessage="";
String organicCMessage="";
String nitrogenMessage="";
String phosphorusMessage="";
String potassiumMessage="";
String zincMessage="";
String username = getIntent().getStringExtra("username");
double pH2 = Double.parseDouble(getIntent().getStringExtra("pH"));
double organicC2 = Double.parseDouble(getIntent().getStringExtra("organicC"));
double nitrogen2 = Double.parseDouble(getIntent().getStringExtra("nitrogen"));
double phosphorus2 = Double.parseDouble(getIntent().getStringExtra("phosphorus"));
double potassium2 = Double.parseDouble(getIntent().getStringExtra("potassium"));
double zinc2 = Double.parseDouble(getIntent().getStringExtra("zinc"));
double temp2 = Double.parseDouble(getIntent().getStringExtra("temp"));
String date = getIntent().getStringExtra("date");
//Temperature Level
if (temp2 >= 24){
tempMessage = temp2 + " is too high";
}
else if (temp2 >= 18 && temp2 <= 24){
tempMessage = temp2 + " falls withing optimal temperature";
}
else if(temp2 < 18){
tempMessage = temp2 + " temperature too low";
}
else
tempMessage = "Incorrect reading";
//pH Level
if (pH2 >= 5.5 && pH2 <= 7.0){
pHMessage = pH2 + " falls in optimal pH";
}
else if(pH2 < 5.5 && pH2>= 0){
pHMessage = pH2 + " might be too acidic";
}
else if(pH2 >7 && pH2 <= 14){
pHMessage = pH2 + " might be too alkaline";
}
else
pHMessage = "Wrong Measurement!";
//Organic carbon level
if (organicC2 < 1.2){
organicCMessage = "Low fertility";
}
else if(organicC2 >= 1.2 && organicC2 <= 1.7){
organicCMessage = "Medium fertility";
}
else if(organicC2 > 1.7){
organicCMessage = "High fertility";
}else
organicCMessage = "Wrong Measurement";
//nitrogen Level
if (nitrogen2 >= 0 && nitrogen2 < 15){
nitrogenMessage = "Level too low";
}
else if (nitrogen2 >= 15 && nitrogen2 < 30){
nitrogenMessage = "Medium level";
}
else if (nitrogen2 >= 30){
nitrogenMessage = "High Level";
}
else
nitrogenMessage = "Wrong measurement";
//Phosphorus Level
if (phosphorus2 >= 0 && phosphorus2 < 25){
phosphorusMessage = "Level too low";
}
else if (phosphorus2 >= 25 && phosphorus2 < 50){
phosphorusMessage = "Medium Level";
}
else if (phosphorus2 >= 50){
phosphorusMessage = "High level";
}
else
phosphorusMessage = "Wrong measurement";
//potassium Level
if (potassium2 >= 0 && potassium2 < 60){
potassiumMessage = "Level too low";
}
else if (potassium2 >= 60 && potassium2 < 100){
potassiumMessage = "Medium level";
}
else if (potassium2 >= 100){
potassiumMessage = "High Level";
}
else
potassiumMessage = "Wrong Measurement";
//Zinc Level
if (zinc2 >= 1.6 && zinc2 <= 3){
zincMessage = "Level too low";
}
else if (zinc2 > 3 && zinc2 < 4){
zincMessage = "Medium level";
}
if (zinc2 >= 4 && zinc2 <= 8){
zincMessage = "High level";
}
else
zincMessage = "Wrong measurement";
date1.setText(date);
/*pHLevel.setText(pHMessage);
organicCLevel.setText(organicCMessage);
nitrogenLevel.setText(nitrogenMessage);
phosphorusLevel.setText(phosphorusMessage);
potassiumLevel.setText(potassiumMessage);
zincLevel.setText(zincMessage);
temperatureLevel.setText(tempMessage);*/
}
}