0

We have been learning how to open new Activities, in class, but so far the second activity runs its logic from the OnCreate() class.

I am wanting to return directly to activity one, from activity two, but run a function in its java when I do so.

All I've been able to find on the matter is how to effectively write my own "back" button.

I am needing to pass a string, as well as an int, that was originally sent from activity one to activity two. I need to compare the received int with the sent int to confirm it is coming from the same source.

My biggest problem is that we were taught to use OnCreate(). This will not work on returning to an Activity, as OnCreate only runs when the instance is first created. If I am creating the instance as I move back, my other function will not work.

Gnemlock
  • 325
  • 6
  • 22

1 Answers1

1

You can just use an startActivityForResult method.

Here is a topic of that: How to manage `startActivityForResult` on Android?

Hope it helps :)

Community
  • 1
  • 1
Francisco
  • 254
  • 3
  • 9
  • Goddamit. it actually says that in the notes. Only its worded like "create a function to run your logic, and call it this to keep it neat". – Gnemlock Aug 11 '15 at 02:27