-7

For example, I have an activity named MyActivity and it doesn't have the function onResume().

So basically what would happen if I resume the activity? Will it call the onCreate() method or something else?

SQB
  • 3,926
  • 2
  • 28
  • 49
Pigeon App
  • 79
  • 1
  • 1
  • 8
  • doesn't need to override this method, its handled by activity life cycle. – Hemant Parmar Feb 16 '18 at 07:16
  • 2
    onResume is the default life cyle method. this will help you to understand.. https://stackoverflow.com/questions/8515936/android-activity-life-cycle-what-are-all-these-methods-for – Aj 27 Feb 16 '18 at 07:16
  • Extended class Activity is already having onResume function. Hope you understand abstract class concept. – Rudrik Patel Feb 16 '18 at 07:19

3 Answers3

0

Even if you didn't write the delegate methods like onResume(), onDestroy(), onPause etc.. those standard life cycle methods will meet all the times when you do the respected activity in the screen.

Whenever you need some functionality to be executed in specific delegate then you would need to override the method in your activity screen java file and put your functionality related code inside the overrided method.

Bethan
  • 971
  • 8
  • 23
0

You have to understand how the activity life cycle goes.

When you first open the activity A

onCreate is called ====> OnStart is called ====> OnResume is called.

When you return to the activity A (FROM A BACK PRESS).

OnStart is called ====> OnResume is called.

Conclusion

If you don't have (on resume) or (on start) implemented then nothing will happen on create won't be called when your activity is resumed.

If you want to call something when your activity is revisited (from a back press), you must implement your code in (onstart) or (onresume). Because (onCreate) is ignored on activity resumes.

Hasan Bou Taam
  • 4,017
  • 2
  • 12
  • 22
0

onResume() is one of the methods called throughout the activity lifecycle. onResume() is the counterpart to onPause() which is called anytime an activity is hidden from view, e.g. if you start a new activity that hides it. onResume() is called when the activity that was hidden comes back to view on the screen.

Hemant Parmar
  • 3,924
  • 7
  • 25
  • 49