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
Asked
Active
Viewed 100 times
1 Answers
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
-
but smsreciever is a class with no screen its a hidden acticity – Engineer Hussein Mawzi May 11 '14 at 12:06
-
intent i = new Intent ( first screen.this, SecondScreen.class) does not work – Engineer Hussein Mawzi May 11 '14 at 12:06
-
See this [link](http://stackoverflow.com/questions/7653279/broadcastreceiver-how-to-start-new-intent) and this [link](http://stackoverflow.com/questions/3849868/startactivity-from-broadcastreceiver) too for that..Just call startActivity() – Lal May 11 '14 at 15:30