Reputation: 27535
I have implemented AppCompatActivity
everything working but onCreate
showing underline then after mouse over it's showing error
overriding method should call super.onCreate();
Although there is super call .
Why it is showing red underline ?
Upvotes: 3
Views: 4031
Reputation: 1402
I just ran into this exact same issue with Android Studio 2.3.2 stable release.
My situation was in a class that extended another class I wrote that extended AppCompatActivity. I actually passed into the first super.onCreate both the savedInstanceState and the layout, and that one called its super.onCreate as expected.
It was strange that of the 20 or so classes with this pattern that only one got the lint error.
Here is how my classes were implemented:
public class MyActivity extends BaseNavActivity {
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState, R.layout.activity_locations);
// stuff
}
}
and
abstract class BaseNavActivity extends AppCompatActivity {
...
protected void onCreate(Bundle savedInstanceState, int resLayout) {
// need to set the theme first
setTheme(R.style.AppTheme2);
// then call super before setting the content view
super.onCreate(savedInstanceState);
setContentView(resLayout);
// stuff
}
}
I solved it the same as the initial answer by going into (on Mac OS X) Android Studio > Preferences > Editor > Inspections and changing the "Missing Super Call" rule to just be a warning.
(Hopefully it is just a lint bug and not something I am doing wrong and will get fixed soon and I can change that warning back to an error since it is normally a helpful check.)
Upvotes: 0
Reputation: 5757
Update : This problem is fixed in Android Studio 1.3 preview 2
This is a known issue with Android Studio 1.3 preview build. It is reporting false positives with the Lint inspection.
You can read about the reported issue here:
https://code.google.com/p/android/issues/detail?id=174964
You can downgrade to the latest Android Studio in the release channel (1.2) or a suggested fix is:
You can cancel the "Lint Inspections" temporarily.
In Android Studio 1.3: Android Studio>Setting>Inspections>Android Lint>Missing Super Call
Upvotes: 4
Reputation: 22212
This problem is fixed in Android Studio 1.3 preview 2 which was released to the canary channel
Upvotes: 1