Application crash on power button - java

I am making a game(Landscape mode) in AndEngine GLES 2.0 and facing very weird problem. When I press power button -> power button -> unlock phone, the game restarts automatically. I've done some testing:
Not working:
Galaxy Nexus (4.2.1)
Xperia Pro (4.0.4)
Working:
Xperia Pro (2.3.4)
I wonder if there is some change in the power button management of 4.0. and above?
If I change my game to portrait mode then there is no problem at all.
I also have placed the orientationChanged settings in the manifest but the problem still exists

I had a problem that was similar, but not resulting in an application crash. Just that the game did not restart successfully. It turned out the problem for me was using static references.
Your problem may be caused by your textures. I don't think its documented anywhere, but using ANY static reference to a texture can cause a number of bad outcomes when resuming a game. However its fine to use a Singleton to manage your textures.

Related

Android WallpaperManager method "soft-bricking" user's phones and causing an unresponsive device

I've had 2 users in the last 2 days report that their phones crashed and remained unresponsive until performing a factory restore while using my app, at the same point. I've found this occurs with other similar apps and believe the reports to be credible, but no other solutions or discussions anywhere. (Google & OnePlus on Android 9.0 SDK 28)
They both describe a blank, black, and unresponsive lockscreen that persists even in safe mode. Only the power button and power menu works while in this "stuck" state. Both users are unrooted, use the same settings, and use the default Android launcher.
Following their reports, the only "dangerous" thing that occurs during their usage is:
WallpaperManager wallpaperManager = WallpaperManager.getInstance(context);
wallpaperManager.setBitmap(bmp, null, false, WallpaperManager.FLAG_SYSTEM);
This runs within an AsyncTask and does nothing special other than the above. I expect it to be an anomaly since it appears it has only been reported twice out of a few thousand users, but it's concerning. I'm not sure if it's an issue with Bitmap leaks, SystemUI, or Android itself.
Yep. setBitmap() is dangerous, image can be too large. If you let users to setup own wallpapers, check image dimensions and resize.

Problems with turning off the autofocus on Android phone

Working on my Samsung S6 camera calibration as a first step for further app development.
One of the perquisites for correctly working app is that the autofocus is disabled.
I used something like this:
mCamera.cancelAutoFocus();
Camera.Parameters mParam = mCamera.getParameters();
mParam.setFocusMode(Camera.Parameters.FOCUS_MODE_INFINITY);
mCamera.setParameters(mParam);
Previously, I checked that the "infinity" focus mode is available on my device.
Still, when running the app, I can clearly see that the focus is changing depending on the distance of the object in frame. "Fixed" mode is not available.
Am I doing something wrong?
I just want to have focus that will not change while running app.
I'm using OpenCV3.1 with Android Studio.
Olivier's answer helped me alot.
Did it as it is described.
Had to edit layout a bit.
Put the setInfinityFocusMode under the onCameraViewStarted.
Thanks Olivier ! ;)

Android Studio - AVD doesn't recognize gestures (cant unlock emulator)

I just started learning to program for android and sadly after making one program (Hello World) I have already ran into an issue. The gesture for "Swipe to Unlock" or for the camera are not functioning. I can bypass it on the stock emulator because it shows a notification i can click that will skip the screen, however i would much rather just figure out a solution, i have searched around on Google and StackOverflow to no avail... maybe someone can help out.
Thanks in advance,
Jon
ok solved! for those that might have the same problem, just press f2
adb shell input keyevent 82
I had the same issue and grew tired of it, this always worked.
AVD_WXGA_TABLET emulator.
Android v 7
F2 does nothing.
Dragging with left-down mouse tries to do a swipe up but bounces back down when I release the mouse.
I've tried fast and slow, release on the virtual device or off it. Short and long strokes. You name it...
The f'ing thing won't unlock. And for all the keystrokes available in the tool pallet including fingerprints, there is no simple swipe-left/up/down/right. You'd think they would have had cntrol-alt-arrow for that out of sheer common sense or as the result of the developer trying to use it.
In my case, I just restarted the simulator by holding down the "Power" button in the simulator menu for a couple of seconds and then choosing "Restart." I was able to unlock the simulator easily after that.
I'm not sure exactly which step solved it, maybe all, but these were my steps
Use the SDK manager to update to the latest version of the emulator
Turn off the emulator (hold the power button and select Power Off)
Close Android Studio
Reopen Android Studio
Launch the emulator from the AVD manager
On mac you can keep holding the command key and then do the swipe gesture with the mouse or trackpad of your computer.
Video
Try using one of two ways
Swipe up from top section of screen
Swipe up from bottom section of screen i.e. just above the navigation buttons.

How to programmatically clear the Camera cache in Android?

I have an issue with Samsung Galaxy tablets. When my application triggers the camera flash, the image gets dark. I never noticed this issue since I was doing testing with other brands. But, recently, I just stared testing with Samsung Galaxy and I found out that issue.
After several days doing research I found that one way to temporally solve it could be clearing the camera cache. Effectively, that works if you do it through the device camera setting, but I need to do it now by code, since I would like to trigger that event before the user uses the camera flash.
How can I accomplish that programmatically ?

libGDX Causing Multitouch Problems

I am working on a game with a virtual joystick in the bottom right corner of the screen and a "move" button in the bottom left. So you use the joystick to point the character in the right direction and press the "move" button to go forward in that direction. This was all working great until today and now when I press on the screen to go forward my joystick is being affected. I know it is not a coding problem because I haven't opened the file that handles touches for 8 days and it has been working fine. Also after I close my app and then use another app that is completely separate from libGDX the multitouch is having the same issue. So do you guys think this is a problem with libGDX, my device, or am I just not coding the multitouch correctly for libGDX? I am using a Stage and the controls are Actors on the Stage I should note that after I restart my phone, the other app that is not using libGDX works correctly. It is only after I open my libGDX based game. So frustrated with this that I am about to give up on libGDX. I am happy to post any code that is requested.
EDIT: Please see comments below. This seems to be a specific issue with the Galaxy Nexus and probably some other Samsung devices as well. This libGDX based app has had no issues on other devices such as original droid, and ASUS Transformer tablet.
Turns out this is not a libGDX problem at all... Nor was it a problem with any of my code. There seems to be a bug in the way the Galaxy Nexus handles multitouch. You can view the bug report at this link. Seems that as of 4.0.4 there still is no fix for this bug. I am still currently running a VZW Galaxy Nexus with 4.0.2, I guess all we can do is wait and put a disclaimer in our games until (if ever) it is fixed.
By locking and unlocking the device, the problem does go away (sometimes), but will quickly come back if I go to my homescreen and re-open the app.

Categories

Resources