I want to detect memory leaks in my Android application. Some leaks could be detected while rotating the phone physically so that the activities are constantly recreated.
I'm looking of some sort of physical device that could turn the phone 90 degrees every X seconds. I could build something using lego Mindstorm (that would actually be very cool), but I'm looking for something cheaper.
I also thought of using a clock, but I couldn't find one that has a clock second hand strong enough. Futhermore if the phone rotate 360 degrees after some time the USB cable would become too twisted. I think a device that goes back and forth between horizontal and vertical would be perfect.
My dream testing machine would also allow me to plug a USB cable so that I can run the Monkey tool while constantly rotating the phone.
Why don't you just force the orientation change or destroy and recreate the views every X seconds? I think it's more reliable than a mechanical approach. I can also recommend you this : http://developer.android.com/guide/developing/tools/monkey.html
You need to trigger configuration change somehow. This might be orientation change, hardware keyboard is opened or hidden, or any other change listed here: android:configChanges.
And there is one way to change configuration without using physical approach. You can use "Car Mode" or "Night Mode". Both only work in Android 8+ and can be turned on/off using UiModeManager.
So you can write your custom Service that will periodically call UiModeManager.enableCarMode(0) and UiModeManager.disableCarMode(0);, which in turn will force configuration changes in your Activity under test.
Perhaps http://mindstorms.lego.com/ Lego MindStorms? To be fair, it's about $250 so not really "throwaway cheap" but the advantage of being fully programmable might outweigh that.
As far as I know it's the cheapest robot kit out there which is why universities and schools use it.
Related
In my situation, I am using the Strava app on a Pixel 2 and noticed that my phone was in battery saver mode at the end of the run. I chalked that up as the reason why my usual running route was 0.2 miles off compared to the previous runs on the same app. Is there a way to view the phone logs to know at what time I may have accidentally put the phone in battery saver mode? I'd like to get an idea of how much of my run was performed without full GPS utilization.
I run on a twisty trail with dense tree cover and elevation changes and therefore I need full GPS functions.
Question
Since there is only one Wake-Lock left with 5.0, what is the way to force the device to go out of standby for 2-5 Seconds and then go back black. No interaction, no unlock of keys... just out of standby. All solutions I found work with deprecated Wake-Locks.
I know it´s a bad idea and Google want to forbid it to me... do this for normal apps makes sense, but I work on a scientific app where I need it and can risk the battery drain.
Can I force a deprecated wake lock to work under a newer OS?
Why I need this?/What I do/2 Devices == Different behavoíour
I have a step counter, write the values to a sqlite db - at a alarm i look to the db and ask for the steps. based on this I do some magic.
Sony: With the Sony Xperia Z1 compact it works, because they don´t stop the sensors while Standby. So no batching.
Samsung: Same app, also step counter as sensor. But here I always get 0 steps when I ask for them in my alarm. A workaround: When I start the device out of standby for a moment and go to black again. My alarm can get the right value. And this is what I need. So I want to activate the display before I ask for the steps. Then the batched sensor data must be in the db and I get the right steps.
So any solutions? Wake-Locks over the service runtime, where my step counter is inside, are not working.
Big thank you, and I am sure for this case there is no duplicate Question. Get points and make me happy. Big Thank you for your help!
I'm making an app that uses the Proximity Sensor while a phone call is in progress. My main issue is that the device doesn't turn the screen off when I hold it up against my face (while talking on the phone). If anyone has a solution as to how to fix this, then my problem will be solved.
Right now though, I'm trying to manually switch the screen off to imitate the normal behavior of the phone app. I looked through a lot of other posts about this but most of them seem to have instructions on how to keep the screen turned ON. My case is the exact opposite... how do I programmatically set the device to turn it's screen off? I don't want it to lock itself or sleep (since the phone call will still be in progress), just turn the screen completely off.
Thanks!
Here's what I need to do. I want to use an Android tablet for science research, but I will need to programmatically control the screen/backlight. Specifically, there is a mode where my app will need to communicate with other systems via WiFi, play sounds, and have the touchscreen active, but the backlight must be completely off; in this mode, the device cannot emit any light, or it will interfere with the science. Obviously, this cannot be sleep mode! Is this feasible?
I've looked around a bit, and this sounds really promising, but it isn't crystal-clear (to me, anyway!) whether this will work. Can anyone vouch for that?
Finally, does it matter which tablet I choose? Basically, there seem to be three possibilities: the backlight is controlled with a switch (doubt that is done anymore), the CPU can only turn it on or off, or the CPU can adjust it fully. Writing this makes me feel rather silly about being concerned, but a Samsung rep yesterday told me I can't do this on the Galaxy. Anyone care to recommend a tablet?
Thanks!
Specifically, there is a mode where my app will need to communicate with other systems via WiFi, play sounds, and have the touchscreen active, but the backlight must be completely off
Android does not support "have the touchscreen active, but the backlight must be completely off". And, you do not have the ability to turn the backlight "completely off" programmatically.
I've looked around a bit, and this sounds really promising
That sets the backlight to be low. Some devices may elect to turn the backlight off when it is set low. That is up to the device manufacturer.
Finally, does it matter which tablet I choose?
See above.
Since its a science research I'm going to assume you may not need to divulge this application and want it in a controlled environment. If this is the case, a little creative thinking suggests that since the touch screen will still react to even if covered by a thin layer of plastic (like the screen protectors for instance) you may be able to apply some opaque vinyl on top of the screen (easy to remove) for doing the experiments.
This may not be useful but since to me it sounded like it could I thought I'd share my thoughts with you on this one. Once you've covered the screen with the vinyl, the rest is as usual, keep screen on, and do your magic.
:)
I read all there is about wake locks and so on. But I want something different. I have three devices to test, and mainly one device sucks really hard. Its the Asus transformer. The main problem, it can't be charged over USB. This means, if I tell it to "stay enabled during debug" the battery is dead after a while.
Also I want to write a small script deploying my app to all three devices once I build (no problem), starting them (no problem), and then ENABLE THE SCREEN (no way till now).
If found this intent, was happy for 23.5 seconds, and then read this:
http://developer.android.com/reference/android/content/Intent.html#ACTION_SCREEN_ON
Is there any way for me to enable the screen. The device is black, the screen is locked, my app starts (this works, seeing debug messages and hear startup sound), but i would have to manually unlock the screen.
I know, its not THAT bad, but when developing UIs I would have to do this like 100 times a day, and this is annyoing. The two little ones could stay on, but the big one (Transformer) would be empty after a while. I just had a thought, maybe I can tell the Transformer only to dim after a while, and to "undim" on startup. Would increase lifetime tenfold.
But still, if anyone knows a way to turn the screen on, that would be fantastic!
Chris
[UPDATE]
Ok, what you can do is reduce the screen brightness after some time, by using this:
WindowManager.LayoutParams WMLP = getWindow().getAttributes();
WMLP.screenBrightness = 0.01F;
getWindow().setAttributes(WMLP);
Dont use 0 as a value (at least not until this question is answered), because the screen will switch off, and you will never get in on again. At least without using your thumb and pressing a button, sooo oldschool...