Reputation: 152206
I am starting following activity:
Intent messageIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse(SMS_PREFIX + number));
context.startActivity(messageIntent);
I want to close it immediately like:
context.startActivity(messageIntent);
context.stopActivity(messageIntent);
How can I do it ?
Upvotes: 1
Views: 97
Reputation: 1589
Why are you calling startActivity in first place?
If you need to do that , you can call finish() in oncreate() method of the new activity and then it will close immediately.
Upvotes: 0
Reputation: 39836
AFAIK you can't.
Activities are finished either by user interaction (AKA: back button) or with an explicit call to finish();
https://developer.android.com/reference/android/app/Activity.html#finish()
finish()
is a public method, so if you have a direct reference to the instance of the activity you can call if from whatever object you want. But not implicitly via intent.
Upvotes: 1