Carnal
Carnal

Reputation: 22064

Android - Start activity without launching

How can I start one activity without actually launching it on screen?

Upvotes: 1

Views: 1777

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007574

For instance: I have 2 activities. Activity A and B. Activity B starts a service as soon it gets launched. But I want to start the service through activity A, so I need to somehow start Activity B from A without showing it on screen

Step #1: Call startService() in Activity A.

Step #2: There is no step #2.

If you want to have some common code, where either Activity A or Activity B can start the service, create a static method, or create a base class that both A and B inherit from.

Upvotes: 1

Related Questions