Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return to Activity after action completed in Android?

Tags:

android

sms

When I start the SMS application using the following methods -- everything works fine up until the point where the message is sent. When I send the message -- it never navigates back to the original activity unless I press the back button. How can I start the SMS activity and then once the message is sent have the parent activity showed again?

This is how I call the SMS app with result.

String message = getMessageString();
    Intent sendIntent = new Intent(Intent.ACTION_SENDTO);
    sendIntent.setData(Uri.parse("sms:" + number));
    sendIntent.putExtra("sms_body", message);
    startActivityForResult(sendIntent, INVITE_COMPLETED);
like image 987
hwrdprkns Avatar asked Jul 30 '10 21:07

hwrdprkns


People also ask

How do I go back to previous activity on android?

Android activities are stored in the activity stack. Going back to a previous activity could mean two things. You opened the new activity from another activity with startActivityForResult. In that case you can just call the finishActivity() function from your code and it'll take you back to the previous activity.

What does finish () do in Android?

On Clicking the back button from the New Activity, the finish() method is called and the activity destroys and returns to the home screen.


1 Answers

It is possible. Just need to add the following extra to your intent:

sendIntent.putExtra("exit_on_sent", true);
like image 94
Misha Avatar answered Nov 09 '22 14:11

Misha