Find out if device has softkeys - android

In recent versions of Android it's possible for devices to either have software or hardware buttons. I'd like to find out which is the case for the device my app is running on.
Some background information: It is possible to hide the softkeys as they are displayed on the screen but if you do this they automatically get shown if the user touches the display which is perfectly fine. Now if you do the same on a device with hardware keys the first touch still gets caught by the system like as if it would show the softkeys again but as there are none, nothing happens and the touch event does not get passed to the app.

You could use ViewConfiguration.hasPermanentMenuKey(), to check for a menu key.

For the Keyboard-question try
getResources().getConfiguration().keyboard
that gives you one of the following:
KEYBOARD_NOKEYS
KEYBOARD_QWERTY
KEYBOARD_12KEY
check for KEYBOARD_NOKEYS.

Related

Why Accessibility service does not respond to onKeyEvent on all nexus devices?

I am creating an app with Accessibility Service and I want to do some task when the back button or home button is pressed.For that purpose I added the following attribute in xml file:-
I added the flagRequestFilterKeyEvents flag.
Also set android:canRequestFilterKeyEvents="true".
The service is responding in other devices except the nexus device.
I am not able to understand that, why its not responding in nexus phones.
please share your knowledge with me.
Back button and Home Button are not keys. The actions may be implemented this way on some platforms (for example the back button could send the "escape" KeyEvent). But, this is NOT required.
In this case "KeyEvent" refers to a hardware keyboard (ex: a bluetooth keyboard). Note: software keyboards can be implemented to send these events as well, but they are not required to, and it should not be relied on.
On Nexus Devices, the back and home buttons are actually on screen software buttons. Thus, like the difference between a hardware and software keyboard, those events are not passed through the system in the same way as devices where there are physical back buttons to press.

Programmatically enter multi-window mode in Android N

Android N has a new feature - Multi Window Mode. It enables two applications to be active side-by-side (actually one one is active, other one is paused but we can see both simultaneously).
I am looking for an API that I can call to have my application enter multi-window mode. I couldn't find much help in Android N SDK docs. I am trying to have two activities of my app run side by side, but without user having to do manual steps.
MANUALLY ENTERING MUTLI-WINDOW MODE
The user can switch into multi-window mode in the following ways:
If the user opens the Overview screen and performs a long press on an activity title, they can drag that activity to a highlighted portion of the screen to put the activity in multi-window mode.
If the user performs a long press on the Overview button, the device puts the current activity in multi-window mode, and opens the Overview screen to let the user choose another activity to share the screen.
The SDK for API 24 introduced a new constant to toggle split screen mode from an accessibility service:
https://developer.android.com/reference/android/accessibilityservice/AccessibilityService.html#GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN
The constant can be passed to following method:
https://developer.android.com/reference/android/accessibilityservice/AccessibilityService.html#performGlobalAction(int)
Google seems to have missed to document the new constant in the performGlobalAction method. I still consider this to be an official API since Google did not mark the constant as hidden.
You have to implement an accessibility service in your app and let the user manually enable the service in system settings->Accessibility so it might not be a viable option for all apps.
As of Android N, this is not supported.
The only supported way to enter multi-window mode is if the user manually triggers it.
I don't think that an api for the thing you want to do exists, You could try making your app have two fragments on each side of the screen. With a black bar in the middle, make each fragment resize according to the "X" position of the bar. :)

android invasive advertising screen from installed app, how to replicate that?

I installed an app on my android phone to safe lock certain apps with a password. Since I installed it, sometimes, regardless what i'm doing on the phone/which app i'm using, a full size screen with advertising appears and I have to click an "X" to close it or press back/home button.
(Can be that this screen appears randomly only when I digited a password to unlock an app therefore the safe lock app was active let's say, not sure.)
I was anyway wondering what sort of code is used for this? Anyone?
I'd need it for a less despicable cause: in order to show a transparent view with alertdialog when my timer is up and the app is closed, to imitate the original builtin countdown timer.

Disable the possibility to hide notifications in Android Lollipop

Since Android Lollipop, the user can hide notifications of an application from Android settings.
I'm writing a parental control application and I'm searching for a way to disable this functionality.
Indeed, I want notifications to be always displayed, even if the child doesn't want to see them.
I saw that on tablets (not on phones) we can create a specific profile to block access to the settings app, but I don't want to lock the settings app, and the trick needs to work on phones too.
I also looked in manifest file to see if an option was there to explicitly enable/disable this but I found nothing.
Please note that my app does have admin privileges.
After hours of head scratching and hundred of coffees, nothing came to me from Android developer website or any other website, I'm desparated.
So finally, is there a way to disable the possibility to hide notifications in Android Lollipop?
Disabling the ability to hide unwanted notification would be undoing what that feature is. As far as I know there is no way to do that.
EDIT:
However - there is an broadcast send after each settings change (WiFi turn on / off etc.). Some settings blocking apps are using this to revert changes made before entering password - maybe there is an intent that does the same for hiding notification.

Android: Getting notified when a screen capture is done

Is there any way to get notified when a screen capture is performed using the soft key or the device hard key on android? Any way that works 2.3 onwards will help greatly.
Use case:
I already block screen capture using FLAG_SECURE. I want to show a Custom Dialog to the user when this action is performed. Android supplied mechanisms vary. Sometimes a notification is seen while at others, a blank screenshot is captured with no user feedback.
Is there any way to get notified when a screen capture is performed using the soft key or the device hard key on android?
No, sorry.

Categories

Resources