Well the problem is, i have livewallpaper that has inside main class a onConfigurationChanged,
the code is
public void onConfigurationChanged (Configuration newConfig){
if(MODE == 0) {
if(newConfig.orientation == Configuration.ORIENTATION_PORTRAIT)
{
scene.setScale(1); //this is line 920
scene.setPosition(0, 0);
}
else if(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
{
scene.setScaleY(1.6f);
scene.setScaleX(0.6f);
scene.setPosition(120, -240);
}
}
else if (MODE == 1)
{
if(newConfig.orientation == Configuration.ORIENTATION_PORTRAIT)
{
scene.setScaleY(0.6f);
scene.setScaleX(1.6f);
scene.setPosition(-240, 120);
}
else if(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
{
scene.setScale(1);
scene.setPosition(0, 0);
}
}
}
It works well, while phone is being ON, but if phone gets restarted that crash occurs
java.lang.NullPointerException
at org.example.example.examplelw.onConfigurationChanged(examplelw.java:920)
at android.app.ActivityThread.performConfigurationChanged(ActivityThread.java:3478)
at android.app.ActivityThread.handleConfigurationChanged(ActivityThread.java:3602)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4517)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
at dalvik.system.NativeStart.main(Native Method)
On my Phones Nexus 4 and Samsung Galaxy S2 works well, and does not crash when phone is restarted, but it crash on some other devices.
This happens on LG-P990 too, what i think is, that when phone is getting restarted it does not have Orientation info, but i dont know why onConfigurationChanged is called?