0

I have 2 activity's and want to send an id to the second one.
in second activity i want to read some requirement`s data from db (such as some config data for example).
i want to know what method of my second activity call first and its guaranteed that run?

YFeizi
  • 1,434
  • 2
  • 26
  • 44

1 Answers1

0

very first method that will be called is onCreate() method.

for getting data from intent:
1) in your 1st activity:

`Intent i = new Intent("your first activity".this , "your 2nd activity class".class);
i.putExtra("id_variable", "id_value");
startactivity(i);` 

2) now coming to your 2nd activity...
-get data from 1st activity
-if you are using AsyncTask class you can get data from 1st intent in onPreExecute method (it will run first)
- than in onPostExecute you can have data from db(using api or anything else)
- than simply call that class in you onCreate() method. :)

Hope that Helps.... :)

Edit:
onCreate will be called for sure... onResume will be called when your app turns into background and returns... onPause will be called when your app is in background....

YFeizi
  • 1,434
  • 2
  • 26
  • 44
kiturk3
  • 528
  • 9
  • 29