Android: Click/Touch Management - android

Big Picture:
User is on their device home screen with an overlay from my application in an arbitrary corner. Overlay is small icon with no functionality (can register if it has been touched) other than presence.
Is it possible to know when the user has clicked OUTSIDE the overlay. I can tell when the user touches the overlay itself, but would like to know if the user has touched the screen but not the overlay?
Does not matter what is being touched, just if the screen is being touched on their device.
Also, same scenario, is it possible to know that the user has clicked a button? For instance, the user clicks the contacts application (or camera, or any application), is their a way to read that action? Do not care what application/button is clicked, just that one was clicked.
Just trying to learn what is possible, so please no need to write out code. Maybe just some pointers in the right direction. Thanks for input.

For the first scenario you can try chat heads(like Facebook messanger) by using intentservice.

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

Perform action on views using their coordinates

I'm trying to access my android device from a web app. I send coordinates from the web app and I want to do a click on long press action on a view at that position.
Is it possible to do that? I think it's possible to get the coordinate of a view and maybe I can store coordinates of few views in an array or something similar and if the coordinate from the web app matches one of the views' position in array, I can do some action on that view..like clicking a button.
So can I click a button, knowing its coordinates?
I know this is quite far fetched, but I want to try. I'm able to view my android device on the web app. Now I'm trying to access it. Sorry if this sounds stupid.
ANY opinion on this would be appreciated.
You should see the following two answers.
The first one is quite straight forward but requires rooted android phone:- Simulating touch event using su
The second uses motion event. In this first you check if the view recieved the event and if it did ,you can use dispatchEvent() function to send the event:- https://stackoverflow.com/a/4692133/1375020

How to prompt the user to unlock the lockscreen, when he/she click on the lockscreen widget?

I have made one widget which basically shows the Rss-feed from a site. When it is clicked upon, it opens the respective link. All is good upto here.
Now when I place it on lockscreen, it responds exactly same like it is on homescreen. I want that when user clicks on the widget, it prompts user to first unlock the screen and then open the browser. How do I achieve this? Help is appreciated. Please let me know if any more information is required. Thanks.

Android: displaying icons on device's desktop

I would like to know how does Facebook messenger work. I mean, I guess there is a service running in the background, with a broadcast receiver. What really baffles me is that when I receive a message, a circle with the person's profile picture pops up on my home screen.
https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQ7ik8VPHOc1oRK3Vf-LtoZPtSPtdtGZzgecoFsK49HXYiKdMV4
How exactly can I achieve that? Displaying icons to the desktop. (No, I do not want to set shortcuts).
I have not used the Facebook app, so I might misunderstand what you want to do, but it might be achieavable with a widget?
If you want a more 'dynamic' experience, without needing the user to place the widget, you can use an Intent or a Broadcast to launch a transparent Activity (here is a SO question on transparent activties). This Activity can then display any views you want to show on top on whatever the user currently is viewing (such as the home screen).

What is the proper way to reference a user interaction on Android?

I'm currently in the process of writing documentation for an app, and was curious of the proper way to reference a user interaction on screen.
i.e.: To advance to the settings screen, tap/touch/click the settings icon.
Since Android is available on so many form-factors, including TV, is it 'tap' or 'touch' or 'click' or something else entirely that maybe encompasses everything? I've checked some other app docs and they all vary.
Thanks in advance.
The documentation of the SDK (agreed, this is for developers, and not end-users) seems to be using the touch word.
See for example the Handling UI Events section, in which you'll find (quoting) :
This is called when the user either
touches the item (when in touch
mode), or focuses upon the item with
the navigation-keys or trackball and
presses the suitable "enter" key or
presses down on the trackball.
Or :
For a touch-capable device, once the
user touches the screen, the device
will enter touch mode.

Categories

Resources