Click on an x and y position in another android application - java

I have a Bluetooth led bulb that will only work with one specific app. I want to create an app that will open the bulb app (iHomentLight) and gradually increase the brightness slider to wake me up in the morning. I want to know if it is possible to do this, and if so how?

Apps are sandboxed so that someone can't use this kind of thing to take advantage of you (and steal your bank info for example). Some apps work around this via accessibility service.
How to perform Other app list item click using accessibility service like Voice Access app?
However, you are probably better off just figuring out what the bluetooth API for your bulb is and teaching your app to work with it. You'll have your app connect directly to the bulb and do it yourself. Search Google for the bulb name and see if anyone has reverse-engineered the API.
Here is an amazing writeup on how to reverse engineer a bluetooth API:
https://medium.com/#urish/reverse-engineering-a-bluetooth-lightbulb-56580fcb7546
Spend some time trying this out, I think it'll be a more useful skill than messing with the accessibility service.

There are around three approaches you can take:
1 - If you have access to iHomentLight's API, you could potentially send a series of intents to the app and have it gradually adjust the light over time.
2 - If that is elusive, I'd recommend trying to sending touch commands via the terminal. For example 'input tap x y android'.
How to run terminal command in Android application?
3 - Or you can use Tasker App to make commands that will adjust the light just as well

Related

How can I implement actions based on my rest API

I have a plan of automating a process via REST api and multiple smart devices. What I am trying to do is the following. I have 4 devices that each do a series of actions to complete their task. (practicaly Im gonna be lighting 4 leds in a particular series based on the device). Im currently emulating this in Java (since I dont have the devices at hand)
So for example lets say device no.1 lights up the red led first for 10 seconds, after that device no.2 needs to light up for 10 seconds etc. That's the task. This is done automatically and forever till I shutdown the program.
I have developed a REST API using JAVA and the JAX-RS library where I state the devices and their info (so device name, current state ex. Yellow Led ON/OFF etc.).
What I dont understand is how I am gonna make the program I have now respond to the info from the API. How can I make my program get notified when a value is changed on the API info?
How can I make device 2 poll the API till it gets the response to start its action? Or make it so it starts the action if i manually change the value on the server data? Example if the yellow led is on, and i go in the server database and put it on off, how will my application get notified and change the state of the simulated led?
Since you are using HTTP, most suitable solution is to use web sockets. You can use them for full duplex communication. When you receive input from one device, you can process it and inform other devices. Note that this is not suitable for a large client base.

How to make an app unclosable?

After a user opens my application I don't want them to be able to get out. So when they press the home or back button it doesn't let them exit the app. I know there are ways using a service to keep the app always running in the background, but I don't even want them to even exit.
Is this even possible, if so how? Without having to hack the kernel.
I know this sounds odd, but it is not for a commercial app, but for my lab, it will never be on GooglePlay. The tablets will be given to little kids and they will take a test on it, so I can't have them using youtube or anything else.
Related post: Android, How to make the task of the app unclosable? Only closable by task killing
The answer by CommonWare seems to indicate that kernel hacking is the only way, but is it?
Also I am using Android L.
there is no official support yet - there will be support with android L via the Task locking API
The L Developer Preview introduces a new task locking API that lets
you temporarily restrict users from leaving your app or being
interrupted by notifications. This could be used, for example, if you
are developing an education app to support high stakes assessment
requirements on Android. Once your app activates this mode, users will
not be able to see notifications, access other apps, or return to the
Home screen, until your app exits the mode.
https://developer.android.com/preview/api-overview.html
EDIT: as you said you use L this got obsolete - but I leave it here as a hint for others
said that - you are also able to get this kind of work without root today if you have to ( e.g. kiosk mode app on a certain hardware ). It is not simple - and no solution that works for all devices - but if you need it you can get it work with tricks like:
- reacting on home-screen intent ( and setting it as default )
- when you go to background - bring your self foreground again
- ..
It seems google has some thing called COSU for setting up single-purpose devices
Android 5.0 Lollipop introduced two new ways to configure Android
devices for a single purpose:
With app pinning, the device user can temporarily pin specific apps to the screen.
With lock task mode, a user can’t escape the app and the Home and Recents buttons are hidden. Additionally, lock task mode gives the IT
administrator a more robust way to manage COSU devices, as discussed
below.
and
As an IT administrator, you can configure Android 6.0 Marshmallow and
later devices as corporate-owned, single-use (COSU) devices. These are
Android devices used for a single purpose, such as digital signage,
ticket printing, point of sale, or inventory management. To use
Android devices as COSU devices, you need to develop Android apps that
your customers can manage.
from here
and there is a code lab for it here
for earlier versions of android here i founded How-To Create a Working Kiosk Mode in Android which shows some hacks for disabling buttons and restarting the application after boot and lock. note that most of these hacks, don't work on android 6 and later

How do they implement reward system in apps/games?

If you noticed, there are more and more apps which are free, but in there they have some kind of currency (gold, fake money, etc.) which you can either buy or earn for free. I am interested in this free earn system.
Namely, you get a popup like "Download and start app XY and you'll earn 5 gold coins". So I download the app and runs it once, then I switch back to app and I immediately receive 5 gold points.
Is there some rewarding system they use or each implements its own?
If they implement their own, how do they check if XY app has been installed ans started?
The way I see it, if I am to implement this on my own, then I contact the owner of XY app and ask him to implement a sample code in the splash of his app/game. When his app is started it send OK flag to my online database. Another service immediately pushes notification to my app and the app know that some user installed and started XY app. But I do not know what should I do in case there is no internet connection during first-launch of XY app?
You don't need an Internet connection; you can just check the list of installed applications, as described here.
Have you tried Scoreloop ? They have a framework which can be integrated into your Android application which will allow you to buy coins, earn trophies, etc, etc....
In addition, they can (for a charge) promote your application with other scoreloop users..

Phone gap camera - is there a more powerful option?

I'm looking to build a companion photo capture app for my photo capture website. I was planning to do this with phone gap.
Upon triggering the camera I want to grab a frame (a still, really) up to five times a second and send it to the server (barring any surprises, The sending part should already be dealt with in code I have). I suppose the realtime video from the camera itself should be displayed to the user as well, though I could just use the stop motion frames for that part.
Unfortunately, according to the phone gap docs, one can only launch the phone's cam app, manually take a picture, then return the user to the app.
I am looking into plugins, but I don't see any massive phonegap plugin repository out there, so I am not sure where to begin. I am just rambling now, so here is a list of bulleted questions:
Is there a plugin out there that does something like this already?
Is there a giant repository of phone gap plugins that I am too foolish to find?
If I try to roll my own java plugin (this is for an android app), what am I really getting myself into? Will I need to know enough to just make the damned thing native? I am pretty exclusively in the JS world at the moment, and am trying to get this out the door asap.
Am I missing something and there is a way to to this with vanilla phone gap?
Any other suggestions?
Thanks!
The phonegap plugins are here:
https://github.com/phonegap/phonegap-plugins

Possible to 'layer' Android applications?

I know this in general is beyond the scope of SO, but I am looking for some basic yes/no info to see if it is even feasible to proceed... I am thinking about building and Android 'note-taking/annotation' app that runs 'over' other installed Android apps, such as the web browser for example.
Essentially, while the user is browsing, my app would be running in the bg as a service, and then they could activate it which would then essentially intercept user inputs and translate those on a transparent canvas over the web browser into lines, shapes, etc. The user could then take a screen-cap of their marking with the underlying web page, which would be stored to the sd card.
This is a very good idea and a great question, but sadly, I do not believe it is possible.
The way Android is designed only one Activity can have focus at a time, while a Service could run in the background, the user would not be able to interact with it. The user can only interact with the currently active Activity.
Again, love the idea, but it is sadly not supported.
You might be able to achieve this with the WindowManager service. You can then use that to call addView() with a view of type TYPE_SYSTEM_ALERT, or possibly TYPE_SYSTEM_OVERLAY (but see the notes in the documentation about taking input focus).
I haven't tried it myself, but I've seen several apps (often dictionary apps that translate whatever words you tap on) that do overlays, and they always seem to require the SYSTEM_ALERT_WINDOW permission.

Categories

Resources