automatically rotate screen in android emulator - android

There are api calls to activity.setRequestedOrientation(orientation) which perform a "soft" rotate, which is not a "hardware" rotate. In other words, it is different from manually pressing Ctrl+F11/F12 to rotate the screen.
In testing of some applications, the behavior of the app could in fact differ due to this subtle difference. For example, ConnectBot crashes when I use the api call to rotate back and forth multiple times.
My question: how can we send host key events to the host emulator process?
UPDATE: I added calls to instrumentation.waitForIdleSync();, but it doesn't help.

Related

Disable recent apps button as device owner

This subject has been beat to death, but I'd like to give it one more shot. Every query I do from this site or basically google give several hint/tips on handling when the button is pressed, but from what I understand the Samsung Knox has the ability to disable the button, and I'm wondering if that's a custom implementation baked into knox or just something i'm completely missing.
My application will be set as the device owner application for other reasons, but I do not see any low level items regarding the recent apps button.
I am currently targeting Android 21 (5.0). We currently use commercial (non root, multiple manufacturer and OS level) phones that we provide with one of our apps being mapped to the home button and monitors accessibility, and the primary application we attempt to keep in the foreground.
A few things...
I'm not interested in making my application a kiosk application so that is not an option for mean at this time.
I can monitor for the Intent.ACTION_CLOSE_SYSTEM_DIALOGS and bring my application to the front (or handle differently), but this still allows for the button to be pressed and the screen to load for a bit.
I've attempted all of the options for getWindow().getDecorView() and setting the flags of SYSTEM_UI_FLAG_HIDE_NAVIGATION, SYSTEM_UI_FLAG_IMMERSIVE_STICKY, SYSTEM_UI_FLAG_IMMERSIVE (different combinations of the flags) during the OnResume, OnWindowFocusChanged, and as a callback listener on the 'setOnSystemUiVisibilityChangeListener'. This works OK for a while but after several pull down attempts on my Pixel 2 the navigation is stuck open.
I'm not very well versed in the capabilities of an application that is the device owner, but I cannot find this lower level configuration option available.
Any help is appreciated

How can I mimic an android process becoming a background process?

I have crashes occurring in my app when the drops in the LRU-application list within androids OS (See http://developer.android.com/guide/components/processes-and-threads.html#Lifecycle). This is due savedInstanceStates not being handled properly. It's really painful and time consuming to constantly have to open my app and then open like ten other applications just to mimic these errors and verify my fixes.
Is there a quick way to mimic this via code?
The way I test those cases is go to Settings > Developer Options. Scroll to the very bottom and enable Don't keep activities. Also, set the Background process limit to No background processes.
Open your app and hit the home button once you are in the activity you want to test and then bring it back from the Recent Apps list.
Hope this helps.

Simulate backstack savedInstanceState behaviour

I want to test the state of my app when it's left in the backstack for too long.
When I open like 20 apps one after the other my last used app (which is the app I'm testing) eventually terminates and a savedInstanceState occurs. Is there a way to simulate this behaviour for the app I'm testing without having to open another 20 apps in order to burry my app in backstack?
Yes, there's a simple way to do it. Just enable Do not keep activities under Developer options. Your activity will then be immediately destroyed as soon you leave it and onRestoreInstanceState() will be invoked when you return.
Alternatively, you can force a configuration change (like orientation) and that will recreate your activity too. One issue with this approach is that there's a bug with some JellyBean/KitKat versions where the emulators fail to rotate. (This works fine on a device though.)
The workaround is to install the RotateScreenOrientation.apk which can force the emulator to be in portrait or landscape but this quickly becomes tedious if you have the option to Wipe user data on emulator start enabled.

Android app on Chrome using ARC, keep back button on top enabled

developer.chrome.com/apps/getstarted_arc#bestpractices
The ARC allows you to execute native android apps through the chrome browser by wrapping a chrome app around it.(As far as I can tell)
I am re-factoring an Android app to work well on Chrome. The first thing I need to do is to make the back arrow enabled at all times on the top left as shown below.
This is the program that allows Native android apps to run through chrome. I think the answer to my question lies somewhere in "Additional Metadata", or in the source code?
Add {"disableAutoBackButton": "true"} to the metadata. That will enable the back button within an activity. I've found that with my app that has multiple activities, though, it doesn't work to return to my main activity from my settings activity. It could be that I'm doing something wrong with the way I'm handling activities, I guess, but it works on all physical devices.
{"sleepOnBlur":false,"disableAutoBackButton":true}
please supply the above metadata before you download the zip or launch app from the arc welder
the first param prevents excessive pause/resume and also supposed to fix short black screen flash occurring occassionally in some of the apps.
the second params adds persistance back button on top left hence helping to avoid extra code required because of absence of back button in some screens(mostly the first screen)

How to tell if a second application has been added to a multi-screen?

On say a Samsung Galaxy S3, it's possible via an application's manifest, to allow it to run in multi-screen mode. Thus when it is running, a second application can be dragged onto the screen and each application then has half (or may be different amounts) of the screen.
When an application is running full screen, how can it tell if another application has been dragged onto the screen, and thus it now only has half of the screen real estate?
The activity is not restarted, and the onConfigurationChange method is not invoked.
Section "3-8-9. Handling Layout Changes" in this document http://developer.samsung.com/s-pen-sdk/technical-docs-09 gives the answer.
Note, you don't need the Samsung SDK to detect the change.

Categories

Resources