Can we create double tap to turn off screen app? - android

i have used some smartphone with this cool function, double tap to screen off, then double tap again to turn on. Really dont need to use physical power button (many user want to avoid this) But not every phone have it built in, my question is can we create an app for a phone without this function and without root?
google search resulted all trash

No. There's no way to get taps when your app isn't the topmost activity, much less when the screen is off.

Related

Screen Dim Event / User Inactivity

first of all, I would like to tell you, what I want to do: I want to get some behavior of iOS on my Android device. Of course, it's just a little detail.
The behavior I talk about is on iOS like that:
The user doesn't use the device
After a short time, the device dims its screen.
Now the user has to tap somewhere on the display to reactivate the device.
THIS IS THE BEHAVIOR I WANT If the user taps on the screen, the screen
will just become active again. The tap itself will NOT cause any other action.
On Android, it's almost the same behavior. Except for step 4: If the user taps on the screen to prevent standby, the tap will already cause actions in the app or home screen or wherever you are.
I decided to develop a small Accessibility Service. This service will show an overlay when the device is inactive and dims its display. Clicking on the overlay will just close it. The overlay itself is no problem and it's already working.
My problem is: I don't know how to find out when the display is dimmed because of inactivity.
My ideas are:
Listen to the Intent.ACTION_SCREEN_OFF event (https://developer.android.com/reference/android/content/Intent).
--> It's working. But it's too late :-( The screen is already completely off when the event has been fired.
Check, if the device is inactive/idle.
--> Is there any possibility to get the status of the whole device? I haven't found anything about that.
Or maybe somebody has completely other ideas?
Thanks for your help.
Greetings
Patrick
You can keep the window screen on & using a TimerTask, dim the brightness of the window manually by some % every, say 5 seconds...
Then when the taps on overlay, Increase the brightness

How to use volume keys to open a activity when device is locked?

Hi all i want make app which run over volume key for example when we press the volume down key it turn camera open( when device is locked) similarly i want the same in my app.
I don't think that's possible
Those functionalities come from the factory OS you have, not from specific apps. The only way that could be possible is by rooting the device, in which case you may be able to listen to physical button clicks and modify their behaviour.
This page shows an application that can alter the buttons behaviour once the device is rooted, but again, this won't teach you how to do it, as again, it's not for the majority of the users and you'd need to root every device.

Detecting reason for the screen turning ON

What I have so far is a Service with a registered BroadcastReceiver for the following actions: ACTION_SCREEN_ON/ACTION_SCREEN_OFF.
So far so good. If the screen goes ON or OFF I get the notification. But this happens for various reasons: user pushes a button (POWER, HOME, etc), battery gets fully charged, incoming call, etc.
What I need is to detect what was the reason for turning the screen ON. And more precisely to detect if it was because of the user pushing power or home button. I've read some opinions that there is no reliable way to do this, but would like to ask again before giving up.
Thanks in advance!

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.

How to disable unlocking screen programmatically

I need to lock the Android phone when the user leaves a defined WiFi area
I need to prevent the user from unlocking the phone when he/she is out side the defined WiFi area
I need to unlock the phone when user is back to the WiFi area
I guess list items 1 and 3 can be done programmatically.
Is it possible to do the 2nd item?
Locking can be done using this method: How to lock the screen of an android device
Unlocking look here: How to display Activity when the screen is locked?
For your problem 2, i see 2 solutions
a. If the user unlocks the screen, a message is fired: check at that moment if you are in the area and if not, instantly lock again
b. create your own locksreen with no possibility to unlock yourself
I need to prevent the user from unlocking the phone when he/she is out side the defined WiFi area
Fortunately, this is not supported, for obvious security reasons.
You are welcome to create your own home screen that offers different behavior when inside/outside a defined area and use that in lieu of trying to prevent a phone from being unlocked. However, the user is welcome to remove that home screen by booting their device into safe mode and uninstalling your app.
I had done similar thing in past but dont have the code right now so cant help in that respect. What I did is implement the app as Car Dock that will make the Home button override unless car-dock mode is dis-abled. I hope this will help, for code google it you definitely find resources
I guess this will help you out. This is just for Disabling the Lock Programmatically.Disable Screen Lock
private Window w;
public void onResume() {
w = this.getWindow();
w.addFlags(LayoutParams.FLAG_DISMISS_KEYGUARD);
w.addFlags(LayoutParams.FLAG_SHOW_WHEN_LOCKED);
w.addFlags(LayoutParams.FLAG_TURN_SCREEN_ON);
super.onResume();
tToast("onResume");
}

Categories

Resources