lacas
lacas

Reputation: 14066

Android how to close an intent?

I've created an intent using

browserIntent   =new Intent(Intent.ACTION_VIEW, Uri.parse(authUrl));

How do I close it? Is it

browserIntent.close 

or something... perhaps

browserIntent.finish();  ?

Upvotes: 1

Views: 8332

Answers (3)

Peter Knego
Peter Knego

Reputation: 80330

You can't.

Your intent starts a new application - browser. You can not close that application (browser) from with your activity.

Workarounds:

  1. You could however put you activity in front from a service (call intent on your activity). The question is based on what user activity would you do that, since you are not receiving user events in service.

  2. If you need user to view some web sites, you could use WebView. This is basically embedded browser that you can control.

Upvotes: 6

EboMike
EboMike

Reputation: 77722

You can't close an intent. An Intent is just what it says - an intent, i.e. something you would like to. An intent by itself doesn't do anything. You're probably refering to an activity, which is the result of calling startActivity on an Intent.

You can't close somebody else's activity. You can just start a new one.

Upvotes: 5

CommonsWare
CommonsWare

Reputation: 1006529

You cannot close another application's activities.

Upvotes: 9

Related Questions