I'm working on writing a program that controls Android device (via USB cable and the Android-SDK toolset).
The program is written in Java, and is addressed for Windows platforms.
The idea is that I get a screenshot of the device's screen every few seconds and show it in a Frame, and then I can simulate taps and swipes on the device's screen using the PC mouse.
So far everything is working as expected.
The thing is I now want to enable the ability of simulating multitouch events on the device, and I was thinking - why can't I receive such events from a multitouch device such as the touch-pad every modern laptop comes with.
How can I do it? is that hardware dependent? Platform dependent? Would I need to implement some sort of interface with drivers for every touch-pad I want to support, or is there a way to do it simply like I write a regular mouse listener?
Related
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'm making an app that tells you how much did you work with your Android device in your day. So I set something like stopwatch but I don't know how to stop it when the Screen goes OFF and how to resume it when Screen turns ON. (even if the app is completely closed)
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.
I want to make an app which will act as the mouse of computer. So how to start please suggest.
Just want to mimic the mouse movement using Android screen
Start by using your real computer mouse and observe its behavior.
Then mimic that behavior in your application.
I have never worked on android before and hence I am presuming that implementing touch/mouse events for a tablet/mobile application might slightly be different compared to events triggered in GUI components of native programming languages.
This question is not related to Android though. If I completely remove all traces of Android OS from a tablet, load and mount it with just a Linux kernel with jvm/jre installed, and few jars that launch a custom java GUI application i.e in such a way that the tablet boots and starts with the custom java application by default, Will this native swing based desktop application respond to mouse events triggered by touch? If yes, is it as good as that in Android?
PS: Precisely, With more emphasis on mouse click, mouse entered and mouse exited events..