0

Hi i am new to Android application development.In my Application i have two activity Activity1 and Activity2.From activity1 i call Activity2 as Intent.I want to access activity1 from this Activity(activity2) without going to first activity is there any posible way?Pls guide me

karthi
  • 1,383
  • 2
  • 10
  • 5
  • What do you mean by access. You want to notify Activity1 from Activity2 or you want to access some members of Activity1 from Activity2 ? Please explain what exactly do you want to do. – Mojo Risin Jul 15 '11 at 13:02
  • for example i want to chage the settext() of Edittext (the edittext was in activity1).The edittext was in fristactivity.i want to change it from secound activity. – karthi Jul 15 '11 at 13:11

4 Answers4

1

The only thing which make sence is passing data from Activity 1 to Activity 2. To do it just pass some data through the intent:

intent.putExtra("key", "Your data here");

in second activity:

String data = getIntent().getExtra("key");

If this is not the case, then your task is wrong somewhere. When activity gone background, there is no sence to interact with it.

Vladimir Ivanov
  • 42,730
  • 18
  • 77
  • 103
0

No, there isn't. Activity1 might even have been shut down.

If you want to pass DATA between the two activities, that's of course doable. Either by passing data on with the intent, by using http://developer.android.com/reference/android/content/SharedPreferences.html or any other storage you can access from both activities.

Stefan H Singer
  • 5,469
  • 2
  • 25
  • 26
0

If from your second activity wants to change something on the previous one, then, instead of using

startActivity(...);

you should use

startActivityForResult(...);

Maybe this link can help.

Finuka
  • 730
  • 7
  • 15
0

So you have the scenario where you start activity B from activity A and you want to change some parameters when activity B is done ( your changes can't be propagated in real time because you can't be sure what is the state of activity A ). So the best way to implement this is to use activity result - for more info about it check Android: Capturing the return of an activity

Community
  • 1
  • 1
Mojo Risin
  • 8,136
  • 5
  • 45
  • 58