0

Is it possible to check how much intent extras is coming from Activity? for example:

Intent intent = getIntent();
float i = intent.getFloatExtra("calculated", calculated);
float j = intent.getFloatExtra("calculated2", calculated2);

r1.setText(String.valueOf(i));
r2.setText(String.valueOf(j));

I know two extras are sending from one activity, can I use if else statements to check if there are more than 2 intent extras are coming to the new activity?

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
Saif Ur Rehman
  • 73
  • 1
  • 1
  • 11
  • have you solved ? – John Joe Apr 11 '17 at 06:51
  • getting intent extras of every values and made some conditions for all values if transferring 3 values to next activity or more than 3.... :D if (k != 0) { r3.setText(String.valueOf("Gauge " + g3 + " Weight Calculated " + k)); } if (l != 0) { r4.setText(String.valueOf("Gauge " + g4 + " Weight Calculated " + l)); } – Saif Ur Rehman Apr 11 '17 at 17:40

1 Answers1

1

You can write something like this in the next activity

String i = getIntent().getExtras().getString("calculated");
.....

    if(calculated!=null)
    {
      // write your logic here
    }
    else if (...){}
    .....

To know the extras count that pass from previous activity

 int num=getIntent().getExtras().size();
 Toast.makeText(getApplication(),"The total is "+num+" ",Toast.LENGTH_SHORT).show();

.size() will return the total extras count.

John Joe
  • 12,412
  • 16
  • 70
  • 135