Why can't I override onConfigurationChanged?
I'm trying to override the method onConfigurationChanged and I get the error:
The method onConfigurationChanged(Configuration) of type BaseActivity must override or implement a supertype method
Here is my BaseActivity.java:
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
public class BaseActivity extends Activity
{
protected View.OnClickListener mButtonListenerUPP;
protected View.OnClickListener mButtonListenerALT;
protected View.OnClickListener mButtonListenerNAV;
protected View.OnClickListener mButtonListenerHIS;
@Override
public void setContentView(int layoutResID)
{
super.setContentView(layoutResID);
}
@Override
public void onConfigurationChanged(Configuration newConfig)
{
setContentView(R.layout.main);
}
}
A lot of posts on the Internet are saying that I can override this method... Any ideas?
Asked by: Blake986 | Posted: 20-01-2022
Answer 1
Have you got android.content.res.Configuration
in your import statements? Eclipse can insert imports automatically if you press Ctrl+Shift+O.
If that's missing, the compiler will be unable to recognise that you're legitimately overriding the superclass method and so will throw an error.
Answered by: Cadie138 | Posted: 21-02-2022Answer 2
Let me guess. SuperNotCalledException.
@Override
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig); // add this line
setContentView(R.layout.main);
}
Answered by: Adelaide990 | Posted: 21-02-2022
Answer 3
Maybe there is a problem with the @Override annotation. Are you sure that both methods annotated with @Override are defined in Activity?
If not you have to remove the respective @Override annotation.
Answered by: Freddie420 | Posted: 21-02-2022Similar questions
java - Why can't I override onConfigurationChanged(Configuration)?
I've already seen the similar question here, and I have already added the line
import android.content.res.Configuration;. It hasn't helped though.
I am writing a class that extends AdapterView<Adapter>, and Eclipse will not let me override onConfigurationChanged(Configuration)
android - When do we need to override callback onConfigurationChanged()?
If we do not want to restart the activity during config changes, we can set flag android:configChanges;
If we need to restart the activity (i.e., to update resources), we should not set the flag.
In what situations, do we need to set flag android:configChanges while overriding the callback onConfigurationChanged()?
android - Conditional restart on Activity onConfigurationChanged
I want to make an activity that allows orientation changes on some condition, but not otherwise. More exactly I want to prevent restarting the activity when a background thread is busy.
I have put the configChanges attribute on the activity manifest, and onConfigurationChanged is called when the orientation changes. However I want to allow the app to change the orientation when all...
android - Changing size of content in HorizontalScrollView when phone is rotated by overriding onConfigurationChanged
Hello fellow Androiders...
I have a problem with resizing content in a HorizontalScrollView when the phone is rotated. I'm overriding onConfigurationChanged in my activity containing the HorizontalScrollView, since I want to handle the resizing myself. However, I'm having great problem finding where i should put the resizing of the content. The HorizontalScrollView it self has FILL_PARENT as width and a fixed heig...
android - onConfigurationChanged-it's still showing the first layout
I have an activity which handles configuration changes. But now i have to change
layout.I tried in onConfigurationChanged callback just to set again the layout and hoping will get the correct layout(land) but it's still showing
the first layout for portrait view ( there two layout(same name) are placed in res/
layout and res/layout-land :)
if I delete android:configChanges="orientation", it works should be, but ...
android - changing orientation through onConfigurationChanged()?
Guys sorry if sounds a little bit naive...
In an activity I have one button and 4 textViews.
According to this post here , I've changed the manifest file and overridden onConfigurationChanged(). I get the desired layout. BUT
the button looses its onClickListener and also textViews change their text t...
android - onConfigurationChanged() is sometimes not calling when rotating faster
This behavior is fond in Android GingerBread. I had override the onConfigurationChanged() to update the layout on changing the orientation of my device.(updated android:configChanges attribute in manifest file.) Also registered an onOrientationChanged() callback in the application. When I change the orientation from one to another it's getting call back for both config and orientation change.(which is the expected one)
android - layout-land xml files does not work with onConfigurationChanged call back
I have different layouts for portrait and landscape mode and I also need to override the onConfigurationChanged() callback. But problem is when I change the phone orientation to landscape my landscape layout does not work.
Can anybody tell me is this onConfigurationChanged call back problem or something else causing that?
Any help will be appreciative.
android - onConfigurationChanged not getting called the first time
I've a problem trying to capture the onConfigurationChanged event. This is the scenario:
Activity A starts (listens to onConfigurationChanged)
Phone rotated to landscape mode (onConfigurationChanged being called). Start activity B.
Activity B starts (listens to onConfigurationChanged) (LANDSCAPE)
Activity B rotates back to portrait...
android - I want the Activity to be fininshed in onConfigurationChanged()
I have an Activity which I want to be finished when user rotates the device.
Here is my code snippet I'm using:
@Override
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
Log.d("Orientation Changed", "Orientation Changed");
this.finish();
}
and in my Menifist.xml I've added the attribute like this.
<activi...
java - onConfigurationChanged() not firing for keyboardHidden
I've followed the various questions and answers here to setup my Android activity to override the onConfigurationChanged() in order to execute logic when the soft keyboard opens and closes. Here's the relevant excerpts from my code. I've boiled it down to the simplest scenario:
AndroidManifest.xml
...
<activity
android:name=".SearchActivity"
android:label...
java - Android onConfigurationChanged() is not being called in Activity
I realize that there are a couple other posts on this topic, however the solutions for those posts are not working for me.
Basically, I want to cease my Activity from restarting upon a device orientation change. To do this, I have modified the activity in the manifest file:
<activity android:name=".MyActivity" android:configChanges="orientation|keyboardHidden"></activity>
Still can't find your answer? Check out these communities...
Android Google Support | Android Community | Android Community (Facebook) | Dev.io Android