This is a problem that kind of baffles me. I'm an experienced developer, but I am pretty new on Android and Xamarin, so I thought I'd mine the ole SO for expert input.
My app has started behaving strangely - sometimes the UI just.. stops drawing things, when exchanging a Fragment. -It's like it just gives up in the middle of drawing, so you can see that for example a label which is supposed to have the text "Search" just has the text "Sea".
Everything else in the fragment is blank, though it seems that the fragment has been created OK, and it has a filled out-layouted view and everything, when I'm debugging.
Interestingly enough; if I switch away from the app, in Android, and then back again - everything is dandy and works fine again!
There's too much code to post - what I'm looking for is clues - what kind of situation is this behaviour a symptom of? What should I start looking for?
The problem was twofold:
We tried to change the text in a UI label, from a timer handler, which was not OK, since the timer handler was in the wrong thread for that
This caused an exception which seemingly crashed the UI thread (I guess!), but due to settings in Visual Studio, this exception was not shown; hence the "unexplainable UI crash"
Related
My misadventures in Android continue, and altho it seems silly to ask about everything, I haven't had any luck with trial-and-error or even Google.
I am using C++ native SDL program in android via NDK.
So first things first: I can't get as simple thing as exiting an application to work. I have fiddled hours with SDLActivity.java and the cpp but nothing seems to work. I mean exiting a program, not just minimizing the process. I know it's not advised but I would like to implement it to some of my programs.
I have tried, according to stuff found online:
System.exit() in SDLActivity
android.os.Process.killProcess(android.os.Process.myPid() ); in SDLActivity
System.finish() in SDLActivity
System.exit(0);
But nothing works, they all just minimize the process but it's still running and continues from the moment of exit when returning
The second thing is about colors. All colors I'm drawing are off when the app is running normally but they appear what they should be when something system messages or the volume dialog appears and then return to the distorted form when it disappears. Is this because perhaps I'm having wrong pixel format for the window? I'm not initializing it to anything specific.
A very strange problem that cause the app to draw ontop of itself without cleaning the previous frame.
Its a bit hard to explain, see the next image:
Some other symptoms of this problem:
If I start it on emulator with GPU, the problem occur.
However if I start the emulator without GPU, it does not.
The actual device that I use is connected to a monitor using HDMI. Maybe it is related.
Any help will be highly appreciated.
This looks like a very similar problem I've posted before (link here) .
The problem is that I tried to use 2 tricks for optimization - have an empty background for both the window and its views.
The reason is that there is the window of the activity already has a default background, but when you remove it, and the views don't have a background, Android doesn't "clear" the content with the background, so it smears...
Do note that this "bug" might occur on some devices yet on others it would work fine.
In short, the solution is to set a background to either the window or its views.
I'm first time developer for these types of devices, and UI in general, so I could be missing something basic and obvious.
Everything seems to work fine in the emulator, but I don't know how to simulate turning it.
So I tried running the app on my pandigital (white model - lowest of the low it seems), and each time I turn the Android, it freezes up. At least the UI freezes up, I believe the debug messages are still printing.
This is a home project, I don't have other devices to try it on.
Sorry for being so vague, it's an issue I have been a bit neglecting, trying to work on more interesting issues first, but it's an issue that is bothering me in the back of my mind.
Anyway, I have an Activity that starts up a thread, and creates a class which responds to various events, it implements: MainInterface and SurfaceHolder.Callback. Is there something else I should be handling? possibly?
Is there some specific call I get when the tablet is turned? I'd like to put a debug message in there.
My guess is that you state in your AndroidManifest.xml that this activity will handle rotation events itself (perhaps because you copied it from some project where the activity did do this), and that this statement is a lie, your activity actually makes no attempt to handle rotation.
If this is the case, a sound way to solve your problem is simply to remove the lying android:configChanges from your manifest.
The error is basically described here. If an activity is finished to quickly after it is created, the UI is locked with an exception: "IllegalArgumentException locking surface" This is a huge problem and I'm looking for the cleanest possible workaround.
Cheers,
Whenever possible I use a Runnable instead of an Activity. However, it is messy to move data in and out of a Runnable. It's a stable workaround, but not clean.
This issue is only seen with short duration Activity instances on the Galaxy Nexus. It does not happen on older Android phones.
I have a weird problem. My android app runs fine I can open other programs and then reopen my app and it has no problem. When i touch the battery icon it closes and it resets all of my data. Does anyone know whats going on?
The basic setup of my app is from this tutorial. I'm having some problems when the application leaves focus it seems to drop out and crash randomly.
After searching through my code I found that my UpdateThread for my custom surface view was not restoring itself properly. So it was pausing and then not copying its values to a new thread when the app got focus again.