• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Key word "super" on main Activity ?

Accolade

Lurker
Jul 7, 2015
6
0
Hi Guys,

I am French and I start in developing Android, so my first questions are going to be very basic!

In our main activity, we have a call to onCreate method of the superclass, like this:
super.onCreate()
Well, but why the call to setContentView method of the superclass is not done also with the keyword "super"?
Like this : super.setContentView()

I tested it : super.setContentView(), it works fine, but why no one uses it that way?

Thank you all ...
 
You have probably defined your own onCreate method in your Activity. If you just call onCreate without super it will call the version you defined. If you want to call the version in the superclass you need to be explicit about it. Since you didn't define your own overloaded version of setContentView you will get the superclass method by default.
 
  • Like
Reactions: scary alien
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones