I have a very unusual crash that happens maybe once a month or so. There doesn't seem to be any rhyme or reason to it. This is part of a large project, and since I'm not sure where exactly the problem is originating, I'm not sure which portions of code to paste here. So instead I will just describe what I am doing, and I think might be causing the crash.
I have an activity with many nested fragments that I manage with the FragmentManager. Because the nested fragments can be of the same type, I have to give the root view of each fragment a unique ID. The app is crashing when calling super.onResume, and that call is the very first line of my overloaded onResume function (so my code is never given the chance to mess anything up). The reason I think it is crashing due to the unique fragment id's is because I started having this problem after moving to unique id's, and the crash always references a low number resource id.
This error seems to be being thrown in the framework itself, so I'm not sure there is anything I can do about it. Has anyone else come across this, and have the figured out a solution for it? Or alternatively, does anyone know if you can surround super.onResume with a try/catch block? I'm not sure whether the app would be able to recover at that point, and there does not seem to be any way to consistently reproduce this error in order to test it.
01-24 20:55:09.602 E/AndroidRuntime( 8156): FATAL EXCEPTION: main
01-24 20:55:09.602 E/AndroidRuntime( 8156): java.lang.RuntimeException: Unable to resume activity {github.daneren2005.dsub/github.daneren2005.dsub.activity.SubsonicFragmentActivity}: android.content.res.Resources$NotFoundException: Unable to find resource ID #0x2
01-24 20:55:09.602 E/AndroidRuntime( 8156): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3014)
01-24 20:55:09.602 E/AndroidRuntime( 8156): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3055)
01-24 20:55:09.602 E/AndroidRuntime( 8156): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)
01-24 20:55:09.602 E/AndroidRuntime( 8156): at android.app.ActivityThread.access$600(ActivityThread.java:151)
01-24 20:55:09.602 E/AndroidRuntime( 8156): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1331)
01-24 20:55:09.602 E/AndroidRuntime( 8156): at android.os.Handler.dispatchMessage(Handler.java:99)
01-24 20:55:09.602 E/AndroidRuntime( 8156): at android.os.Looper.loop(Looper.java:155)
01-24 20:55:09.602 E/AndroidRuntime( 8156): at android.app.ActivityThread.main(ActivityThread.java:5454)
01-24 20:55:09.602 E/AndroidRuntime( 8156): at java.lang.reflect.Method.invokeNative(Native Method)
01-24 20:55:09.602 E/AndroidRuntime( 8156): at java.lang.reflect.Method.invoke(Method.java:511)
01-24 20:55:09.602 E/AndroidRuntime( 8156): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
01-24 20:55:09.602 E/AndroidRuntime( 8156): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796)
01-24 20:55:09.602 E/AndroidRuntime( 8156): at dalvik.system.NativeStart.main(Native Method)
01-24 20:55:09.602 E/AndroidRuntime( 8156): Caused by: android.content.res.Resources$NotFoundException: Unable to find resource ID #0x2
01-24 20:55:09.602 E/AndroidRuntime( 8156): at android.content.res.Resources.getResourceName(Resources.java:1666)
01-24 20:55:09.602 E/AndroidRuntime( 8156): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:919)
01-24 20:55:09.602 E/AndroidRuntime( 8156): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
01-24 20:55:09.602 E/AndroidRuntime( 8156): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
01-24 20:55:09.602 E/AndroidRuntime( 8156): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
01-24 20:55:09.602 E/AndroidRuntime( 8156): at android.support.v4.app.FragmentActivity.onResume(FragmentActivity.java:445)
01-24 20:55:09.602 E/AndroidRuntime( 8156): at github.daneren2005.dsub.activity.SubsonicActivity.onResume(SubsonicActivity.java:130)
01-24 20:55:09.602 E/AndroidRuntime( 8156): at github.daneren2005.dsub.activity.SubsonicFragmentActivity.onResume(SubsonicFragmentActivity.java:250)
01-24 20:55:09.602 E/AndroidRuntime( 8156): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1266)
01-24 20:55:09.602 E/AndroidRuntime( 8156): at android.app.Activity.performResume(Activity.java:5148)
01-24 20:55:09.602 E/AndroidRuntime( 8156): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2997)
01-24 20:55:09.602 E/AndroidRuntime( 8156): ... 12 more
01-24 20:55:09.602 W/ActivityManager( 596): Force finishing activity github.daneren2005.dsub/.activity.SubsonicFragmentActivity
Edit: Added unique id generation. In onCreateView I use rootView.setId(rootId):
public SelectDirectoryFragment() {
super();
rootId = getNewId();
}
#Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
if(bundle != null) {
int tmp = bundle.getInt(Constants.FRAGMENT_ID, -1);
if(tmp > 0) {
rootId = tmp;
}
entries = (List<MusicDirectory.Entry>) bundle.getSerializable(Constants.FRAGMENT_LIST);
restoredInstance = true;
}
}
#Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt(Constants.FRAGMENT_ID, rootId);
outState.putSerializable(Constants.FRAGMENT_LIST, (Serializable) entries);
}
protected int getNewId() {
for (;;) {
final int result = nextGeneratedId.get();
// aapt-generated IDs have the high byte nonzero; clamp to the range under that.
int newValue = result + 1;
if (newValue > 0x00FFFFFF) newValue = 1; // Roll over to 1, not 0.
if (nextGeneratedId.compareAndSet(result, newValue)) {
return result;
}
}
}
Check anywhere in your Fragment or Activity that you might be doing a setText() call. It's possible you're trying to set the text to the String.valueOf() value of an integer, but setText() also has an overload which takes an integer resource value (e.g. R.string.my_string). I've seen this crash when I mistakenly did something like the following:
int myCount = doSomeCalculation();
textView.setText(myCount);
This will internally try to resolve myCount as a resource (e.g. getString(myCount)) rather than setting the text to the string value of the myCount variable.
EDIT: Wait, how are you setting this unique ID on your Fragment's root?
Related
I am trying to build an app in AOSP, my development kit has HDPI density, I have double verified it with the following code snippet:
switch (getResources().getDisplayMetrics().densityDpi) {
case DisplayMetrics.DENSITY_LOW:
Log.d(TAG, "\n\n\n\n LDPI \n\n\n\n");
break;
case DisplayMetrics.DENSITY_MEDIUM:
Log.d(TAG, "\n\n\n\n MDPI \n\n\n\n");
break;
case DisplayMetrics.DENSITY_HIGH:
Log.d(TAG, "\n\n\n\n HDPI \n\n\n\n");
// ...
break;
case DisplayMetrics.DENSITY_XHIGH:
Log.d(TAG, "\n\n\n\n XDPI \n\n\n\n");
// ...
break;
}
when I build my application in Android File system,and if I run it, then I am getting following error:
E/AndroidRuntime( 825): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class android.widget.Button
E/AndroidRuntime( 825): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
E/AndroidRuntime( 825): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
E/AndroidRuntime( 825): at android.app.ActivityThread.access$600(ActivityThread.java:123)
E/AndroidRuntime( 825): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
E/AndroidRuntime( 825): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 825): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 825): at android.app.ActivityThread.main(ActivityThread.java:4424)
E/AndroidRuntime( 825): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 825): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 825): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime( 825): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime( 825): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 825): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class android.widget.Button
E/AndroidRuntime( 825): at android.view.LayoutInflater.createView(LayoutInflater.java:606)
E/AndroidRuntime( 825): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
E/AndroidRuntime( 825): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
E/AndroidRuntime( 825): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
E/AndroidRuntime( 825): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
E/AndroidRuntime( 825): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
E/AndroidRuntime( 825): at android.view.LayoutInflater.parseInclude(LayoutInflater.java:823)
E/AndroidRuntime( 825): at android.view.LayoutInflater.rInflate(LayoutInflater.java:729)
E/AndroidRuntime( 825): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
E/AndroidRuntime( 825): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
E/AndroidRuntime( 825): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
E/AndroidRuntime( 825): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
E/AndroidRuntime( 825): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
E/AndroidRuntime( 825): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
E/AndroidRuntime( 825): at android.app.Activity.setContentView(Activity.java:1835)
E/AndroidRuntime( 825): at com.example.MainActivity.onCreate(MainActivity.java:96)
E/AndroidRuntime( 825): at android.app.Activity.performCreate(Activity.java:4465)
E/AndroidRuntime( 825): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
E/AndroidRuntime( 825): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
E/AndroidRuntime( 825): ... 11 more
E/AndroidRuntime( 825): Caused by: java.lang.reflect.InvocationTargetException
E/AndroidRuntime( 825): at java.lang.reflect.Constructor.constructNative(Native Method)
E/AndroidRuntime( 825): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
E/AndroidRuntime( 825): at android.view.LayoutInflater.createView(LayoutInflater.java:586)
E/AndroidRuntime( 825): ... 29 more
E/AndroidRuntime( 825): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f02000d a=-1 r=0x7f02000d}
E/AndroidRuntime( 825): at android.content.res.Resources.loadDrawable(Resources.java:1897)
E/AndroidRuntime( 825): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
E/AndroidRuntime( 825): at android.widget.TextView.<init>(TextView.java:620)
E/AndroidRuntime( 825): at android.widget.Button.<init>(Button.java:108)
E/AndroidRuntime( 825): at android.widget.Button.<init>(Button.java:104)
E/AndroidRuntime( 825): ... 32 more
My all the drawable resources are in drawable-hdpi.
But if I put drawables in all the drawable-* folder then app runs.
But then UI is getting scattered.
Does anybody have idea, what the problem could. Do I have to add any Variable or flag in the Android.mk
=========edit=========
The app works fine if I build with eclipse. And run on the same device.
Therefore issue might be in building app along with AOSP.
========================
Any help would be highly appreciated.
Regards,
Yuvi
So after struggling too long and googling for more then two days, I found the issue. There was no drawable-hdpi folder in apk. I have resolved the issue by adding the LOCAL_AAPT_FLAGS += -c mdpi,hdpi,xhdpi line in Android.mk file.
Those who are struggling with the same kind of problem follow these supper steps:
Check at which line it is giving error:
Binary XML file line #11: Error inflating class android.widget.Button
In my xml file it was:
<Button
android:id="#+id/btn_footer_back"
style="#style/normalButtonStyle"
android:layout_width="wrap_content"
android:layout_height="60px"
android:layout_marginRight="1dp"
android:background="#drawable/button_state_selector"
android:drawableLeft="#drawable/ic_back"
android:drawablePadding="10px"
android:text="#string/back"
android:visibility="gone" />
So, what is the next step now, the log itself tells the story, check the line:
Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f02000d a=-1 r=0x7f02000d}
Here r=0x7f02000d is the resource id, that you can find in yourproject/gen/R.java
if you search for 0x7f02000d in R.java then you will able to find which resource is creating the problem, in my case it was R.drawable.ic_back
Hope it helps other to resolve their problems.
Regards,
Yuvi
Your UI is scattered because your files are not matching to appropriate density or resolution while displaying on device. You should use density independent pixels in xml.
And Create Drawable folder and put your files in it. And give reference of the drawable folder.
My appwidget crashes with following error:
E/AndroidRuntime( 5572): FATAL EXCEPTION: main
E/AndroidRuntime( 5572): java.lang.RuntimeException: Unable to start receiver com.android.mlweatherwidget.WeatherWidgetLarge: java.lang.RuntimeException: system server dead?
E/AndroidRuntime( 5572): at android.app.ActivityThread.handleReceiver(ActivityThread.java:1805)
E/AndroidRuntime( 5572): at android.app.ActivityThread.access$2400(ActivityThread.java:117)
E/AndroidRuntime( 5572): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:981)
E/AndroidRuntime( 5572): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 5572): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 5572): at android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime( 5572): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 5572): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 5572): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime( 5572): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime( 5572): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 5572): Caused by: java.lang.RuntimeException: system server dead?
E/AndroidRuntime( 5572): at com.android.mlhome.appwidget.AppWidgetManager.getAppWidgetIds(AppWidgetManager.java:375)
E/AndroidRuntime( 5572): at com.android.mlweatherwidget.WeatherWidgetLarge.onReceive(WeatherWidgetLarge.java:202)
E/AndroidRuntime( 5572): at android.app.ActivityThread.handleReceiver(ActivityThread.java:1794)
E/AndroidRuntime( 5572): ... 10 more
E/AndroidRuntime( 5572): Caused by: android.os.DeadObjectException
E/AndroidRuntime( 5572): at android.os.BinderProxy.transact(Native Method)
E/AndroidRuntime( 5572): at com.android.mlhome.appwidget.ILauncherAppWidget$Stub$Proxy.getAppWidgetIds(ILauncherAppWidget.java:256)
E/AndroidRuntime( 5572): at com.android.mlhome.appwidget.AppWidgetManager.getAppWidgetIds(AppWidgetManager.java:369)
E/AndroidRuntime( 5572): ... 12 more
Can anybody understand from the above log what exactly is causing this error?
How to fix android.os.DeadObjectException android X
this guy met the same issue, check this link out.
I copyed the answer written by Dimitar Dimitrov as follows
This means that your service had already stopped - either killed from
the OS, or stopped from your application.
Does this problem happen every time you debug your project?
Override your service's onDestroy() method and watch what event flow
leads to it. If you catch DeadObjectException without going through
this method, your service should have been killed by the OS.
Started getting a ClassCastException in a widget I've been working on that I'm not sure what it's having an issue with. I haven't modified the configure class, nor the configure layout, yet I've started getting a stack trace leading back to my configure class after modifying the main layout
E/AndroidRuntime( 2010): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.metatroid.minimal.music/
com.metatroid.minimal.music.Configure}: java.lang.ClassCastException: android.widget.RadioButton
E/AndroidRuntime( 2010): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
E/AndroidRuntime( 2010): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
E/AndroidRuntime( 2010): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
E/AndroidRuntime( 2010): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
E/AndroidRuntime( 2010): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 2010): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 2010): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 2010): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 2010): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 2010): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 2010): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime( 2010): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 2010): Caused by: java.lang.ClassCastException: android.widget.RadioButton
E/AndroidRuntime( 2010): at com.metatroid.minimal.music.Configure.onCreate(Configure.java:39)
E/AndroidRuntime( 2010): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime( 2010): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
E/AndroidRuntime( 2010): ... 11 more
Reverting my changes causes the issue to go away, but I'm not doing anything with this file, nor am I modifying any RadioButtons...so what the hell? The line #39 of Configure.java is
EditText prv = (EditText) findViewById(R.id.previous_input);
I don't see how that ties into anything. And the only changes I am making to the entire project are changing some TextViews into Buttons in my main.xml layout which is not referenced in Configure.java. Reverting the Button back to TextView makes the error go away. What causes a "ClassCastException" and what could possibly be going on here?
Try clean your project. Previously you had RadioButton.
In an Android app, I've got an activity that is somewhat complex and may have threads running at certain times which, when finished, will update the UI. As such, having the Activity destroy and create again (due to orientation change) in the middle of one of these threads could lead to the user having to re-try that action, which is bad.
As such, I've decided to handle orientation changes myself by having android:configChanges="orientation|keyboardHidden" in the manifest, and can then override the Activity.onConfigurationChanged(Configuration newConfig) method.
The root layout for this activity is a RelativeLayout.
Currently, I don't actually do anything in onConfigurationChanged() other than call the super().
After an orientation change, the layout is muddled - some elements which are android:layout_above= are either at the bottom of the screen, or floating way above what they should be floating above.
Does anyone have any ideas as to how to fix this?
I'm aware that if I allowed the activity to restart upon an orientation change, it would then use a layout from res/layout-land/, but restarting the activity really seems to be the wrong way to go here.
Edit:
I've tried to setContentView(R.layout.displaymap); in the onConfigurationChanged() method and get the following error:
I/WindowManager( 571): onOrientationChanged, rotation changed to 1
D/StatusBar( 571): updateResources
E/AndroidRuntime( 3813): android.view.InflateException: Binary XML file line #17: Error inflating class java.lang.reflect.Constructor
E/AndroidRuntime( 3813): at android.view.LayoutInflater.createView(LayoutInflater.java:512)
E/AndroidRuntime( 3813): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:564)
E/AndroidRuntime( 3813): at android.view.LayoutInflater.rInflate(LayoutInflater.java:617)
E/AndroidRuntime( 3813): at android.view.LayoutInflater.rInflate(LayoutInflater.java:620)
E/AndroidRuntime( 3813): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
E/AndroidRuntime( 3813): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
E/AndroidRuntime( 3813): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
E/AndroidRuntime( 3813): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:309)
E/AndroidRuntime( 3813): at android.app.Activity.setContentView(Activity.java:1626)
E/AndroidRuntime( 3813): at com.apps.virtualtravel.DisplayMap.onConfigurationChanged(DisplayMap.java:1065)
E/AndroidRuntime( 3813): at android.app.ActivityThread.performConfigurationChanged(ActivityThread.java:3383)
E/AndroidRuntime( 3813): at android.app.ActivityThread.handleConfigurationChanged(ActivityThread.java:3449)
E/AndroidRuntime( 3813): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1762)
E/AndroidRuntime( 3813): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 3813): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 3813): at android.app.ActivityThread.main(ActivityThread.java:3948)
E/AndroidRuntime( 3813): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 3813): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 3813): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
E/AndroidRuntime( 3813): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
E/AndroidRuntime( 3813): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 3813): Caused by: java.lang.reflect.InvocationTargetException
E/AndroidRuntime( 3813): at com.google.android.maps.MapView.<init>(MapView.java:237)
E/AndroidRuntime( 3813): at java.lang.reflect.Constructor.constructNative(Native Method)
E/AndroidRuntime( 3813): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
E/AndroidRuntime( 3813): at android.view.LayoutInflater.createView(LayoutInflater.java:499)
E/AndroidRuntime( 3813): ... 20 more
E/AndroidRuntime( 3813): Caused by: java.lang.IllegalStateException: You are only allowed to have a single MapView in a MapActivity
E/AndroidRuntime( 3813): at com.google.android.maps.MapActivity.setupMapView(MapActivity.java:180)
E/AndroidRuntime( 3813): at com.google.android.maps.MapView.<init>(MapView.java:279)
E/AndroidRuntime( 3813): at com.google.android.maps.MapView.<init>(MapView.java:254)
E/AndroidRuntime( 3813): ... 24 more
You have to create layout for landscape mode if you want to set for landscape and put the layout in layout-land folder with same name which is for portrait and than setContentview(R.layout.name) in onConfigChanged method. this will give the desired UI.other wise you will face issue in RelativeLayout.
I have a little issues with an GLSurfaceView, when I start my Activity I make the GLSurfaceView invisible with this line of code:
glSurface.setVisibility(View.INVISIBLE);
During this time I start an AsyncTask which downloads an Image from network, at this time, if I press the back button I meet this Exception:
java.lang.NullPointerException
E/AndroidRuntime( 1847): at android.opengl.GLSurfaceView.onDetachedFromWindow(GLSurfaceView.java:530)
E/AndroidRuntime( 1847): at android.view.View.dispatchDetachedFromWindow(View.java:6033)
E/AndroidRuntime( 1847): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1156)
E/AndroidRuntime( 1847): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1156)
E/AndroidRuntime( 1847): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1156)
E/AndroidRuntime( 1847): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1156)
E/AndroidRuntime( 1847): at android.view.ViewRoot.dispatchDetachedFromWindow(ViewRoot.java:1630)
E/AndroidRuntime( 1847): at android.view.ViewRoot.doDie(ViewRoot.java:2671)
E/AndroidRuntime( 1847): at android.view.ViewRoot.die(ViewRoot.java:2641)
E/AndroidRuntime( 1847): at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:218)
E/AndroidRuntime( 1847): at android.view.Window$LocalWindowManager.removeViewImmediate(Window.java:436)
E/AndroidRuntime( 1847): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3684)
E/AndroidRuntime( 1847): at android.app.ActivityThread.access$2900(ActivityThread.java:125)
E/AndroidRuntime( 1847): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
E/AndroidRuntime( 1847): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 1847): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 1847): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 1847): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1847): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 1847): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 1847): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidR
What's wrong?
It could be that you haven't set the renderer.
From the android reference:
onDetachedFromWindow ()... Must not be called before a renderer has been set.
So, if you set the renderer (even if you aren't rendering anything yet), this might avoid the issue.