If this logic needs to populate some UI components based on the result and just once before UI rendering , then the answer is onCreate()

Condition 2:

Whenever the Activity is in foreground and you need some logic , then onResume() would prefer. Some other Activity may get pushed on top of this Activity and the value changes due to some business logic. Now its should be in onResume()