I am currently working on a health-based project focusing on a person smartphone usage. And for that i want to monitor his touch-screen usage pattern i.e how long he has been pressing his hands on the screen.
When this limit crosses a thresh-hold value will be generated warning to him.
I need to know will i be able to track down a person screen-usage in background (i.e. while he uses all other apps in his phone)
If so which functions would help me ??
Android does not support this, for privacy and security reasons.
You are welcome to intercept all screen touches, to find out when the user touches the screen. However, then the screen touches will not be available to the underlying apps, and so user will not be able to use the device.
You are welcome to look at implementing an AccessibilityService, to be able to find out about user input in all apps. However, last I checked, this does allow you to find out "how long he has been pressing his hands on the screen".
You are welcome to create a custom Android ROM that bakes in your desired monitoring, then deploy that custom ROM on whatever devices you choose to support. With your own build of Android, you can do pretty much whatever you want, but then you are not making a simple app.
On a rooted device, you can probably run something with superuser privileges to track all user inputs, but I do not have the details about how to do that.
So far, there are similar questions asked in here as well. Most commonly, some users suggest defining a window layout stays on the screen as always and capture touch events with onTouch(View v, MotionEvent event) function. But it seems, it is not available anymore (after Android 5.0).
One thing I can suggest that, if the device is rooted, you can execute
"su getevent -lt" command and write the output in a BufferReader. That way you can capture the touch events.
Related
I want to code my own clock, replacing the one on the lock screen. Not to sure how to do this? I only designed app that displays data from firebase. Is there a way to display using flutter or java, information like a clock or a graph on the lock screen? I can only find examples of full screen notifications.
nope, there is no option for that. Lock screen is a separated built-in app which can't be changed by other software
BUT you can write own lock screen app, with own clock. But remember to handle other common/important features, like validating user, showing (all/non-private) notifications, allowing 112 call etc. Lot to do
So recently my phone was stolen and besides all the trouble I had with the lost files I was pretty angry about the fact that it didn't came to my mind to create an app for android that prevents easy stealing or to be precise that will act as a Trojan horse inside of the thief's pocket. So what i thought about is an application that kicks in whenever you're holding your standby button or whatever you usually do to shutdown your phone. This application then looks like the real shutdown menu and asks you to shutdown with a pin or without one and whenever you shutdown without the right pin the phone will actually fake shut down in a way where it is still transmitting GPS and connecting to the next transmission tower so it is easily locatable (by fake shutdown I mean a black screen and silent mode until you are repeating the same method you used to shut your phone down). So is there any way of creating an app that has a higher priority than the android shutdown system so a custom menu pops up whenever you're trying to shutdown your phone?
Your idea isn't entirely impossible for Android.
There is no way for an app to have a higher priority than the Android Shutdown menu. However, that doesn't mean there's no hope.
If you remember popular Alarm apps, they typically have a feature that prevent you from turning off your phone when the alarm rings. This is usually done by detecting that a Long Press of the Power Button is pressed and then dismissing the Power Off Menu.
You can look at this answer for how to do this: https://stackoverflow.com/a/53679477
However, this is just so you can dismiss Android's Power Off Menu so you can show your own Power-Off Menu.
Afterwards, with your idea of displaying a Black Screen and Silent Mode... there's actually four three problems.
Screen Backlight for non AMOLED screens
Status and Navigation Bars
Can't block a Forced Shutdown
Personally, during the early days of Android and my early years of Android development, I released an app with a similar idea (have the phone give off the illusion of being turned off, so there's a higher possibility of phone remaining on if stolen), but due to those four problematic areas, the app has been retired.
So I speak with experience in saying that:
A black screen doesn't play nicely with screens that require a backlight. Even at lowest brightness settings, a completely black screen will still easily be seen as on.
Android doesn't have a way permanently hide the Navigation and Status bars. The best you'll get is Immersive Mode, but this mode will cause the bars to temporarily appear if you touch the screen. Even if you use a Full-Screen Activity, swiping down or swiping up will still show these bars. I believe your only option for hiding both of these bars is Root.
There's absolutely no way to block someone from doing a force shutdown. This completely bypasses the Power Off Menu and it's simply unblockable. So while your app might block some thieves, it might not block the more paranoid ones.
Hopefully, my answer is enough to nudge you in the right direction for your app.
I am just creating a quick application in which there would be a floating icon on the home and the user have to just drag and drop that icon to the app and then it will show a alert window.
I know how to create the floating icon using some maths and windowmanager but don't know how should i get the name of the app on which the floating icon is dropped. I have thought of some ways to archive this, but don't know how to implement it....
By Getting the position of the touch when ACTION_UP Trigger is occurred and then checking what's the app is by comparing it with its position.
But there is a problem in this way, because i don't know how to get the position of launching icons on the homepage.
Help me to archive this task. Please tell me How can i get the position of launching icon(like facebook, google play) on the homepage . Also it would be very helpful if you can suggest me other ways of doing this.
I know this can be done because winners of techcrunch hackathon have
made the same application. A short video of this can be found here, in
case you might want to look,
http://techcrunch.com/2015/09/20/disrupt-sf-2015-hackathon-winners/
i don't know how to get the position of launching icons on the homepage.
That is not possible in general, outside of perhaps the accessibility APIs.
Please bear in mind that there are > 1 billion Android devices in use. Those span thousands of device models, representing hundreds or thousands of home screen implementations. Users can also install third-party home screen implementations (e.g., from the Play Store) and use those.
There is no requirement that a home screen have "launching icons" that meet your expectations. I could write a home screen whose app launcher consisted of text hyperlinks, for example. Or, I could write a home screen that is designed to be used by an external keyboard, where launching apps is triggered by keypresses rather than icons.
There is no requirement that a home screen have some sort of API that, given some X/Y coordinate on some arbitrary piece of that home screen, would tell you an app that is represented by something visual at that X/Y coordinate.
You are welcome to try using the accessibility APIs to find details of a widget at the desired X/Y coordinate on the current screen. However, from there, you would have to make guesses as to whether or not that is a launcher icon and, if so, what app it would represent. This approach is likely to be unreliable, except for specific scenarios that you have hard-coded. Hard-coding is what the team you cited appears to have done, based on the prose on the TechCrunch site.
As u know, there are many solutions and codes on stackoverflow for simulating touch on your own app you are developing.
So my question is that i wanna touch a view on other application with my own application.
How can we do this?
Just imagine i wanna click on X,Y position of the screen each X seconds.
Generally speaking, you can't.
You are welcome to write an AccessibilityService. However, this has only limited ability to manipulate other apps, and it requires users to not only install your app but agree to allow your app to have wide access to all their existing app's UIs.
I wanted to understand how does the Android OS figure out which home screen the user is viewing currently and render the appropriate icons and widgets on that screen based on the user's left or right swipe on the touch screen of the device.
The OS must save a state of the screen and IDs or something relative to the objects placed on the screen to retrieve the state each time the screen becomes visible.
From my research I understand that Android OS treats all the 7-8 homescreens on devices as one single host.
Also my question might seem vague, but the reason why I am asking is because it seems reasonable that app widgets on android devices, update not only when the phone is awake but also only when the app widget itself is visible. I know that Google has declined the enhancement request by many others but I don't think that is good enough. Link here.
That is the reason why I am trying to give it a shot to understand and implement it for my app with whatever Android knows about the state of the home screens.
Any help or insight is much appreciated. Also the experts out there let me know if you think this can be even implemented for one off apps at all?
Well, as the link you posted clearly states, there's no way to know.
Also, if you consider the fact that "Home" is just an application like all the others, it makes even less sense to have a unified API for that. A lot of people use Launcher Pro or similar applications, which would probably not implement it.