views:

62

answers:

2

Hi, I am implementing a simple app. I need to start an activity based on the state of the Activity. Lets take i am using a button to start the activity. 1. If the activity is not started, I need to start XYZ activity. 2. If the XYZ activity is on focus, then i need to close the activity on the button press. 3. If the XYZ activity is not in focus (like onPause) state then, I need to change the button state.

Can you please help me in the flags that i need to use for starting the intent. Is it possible to get the state of activity before I start that activity?

A: 

Try this

Intent intent = new Intent(currentActivity.this, callingActivity.class); startActivity(intent);

You can use intent like this to call an activity

RockOn
A: 

The button press will need to be captured by each activity separately, so just code the different responses into each different activity.

fredley