0

Iam building Android application that checks the format of the received message if it starts with $A its starts Activity A and send the content of the message to Activity A if it starts with $B it starts Activity B and send the content of the message to Activity B Please Any help

1 Answers1

0

You can do it like this

if(messages.getMessageBody().contains("$A")) {

     //Write your code here

}
else if(messages.getMessageBody().contains("$B")) {

     //Write your code here

}

And to pass data to the next activity,do it like this,,

Intent i = new Intent(FirstScreen.this, SecondScreen.class);   
i.putExtra("STRING_I_NEED", strName);

Then, to retrieve the value try something like:

String newString;
if (savedInstanceState == null) {
    extras = getIntent().getExtras();
    if(extras == null) {
        newString= null;
    } else {
        newString= extras.getString("STRING_I_NEED");
    }
} else {
    newString= (String) savedInstanceState.getSerializable("STRING_I_NEED");
}
Lal
  • 14,726
  • 4
  • 45
  • 70