Android Wear - Enable / Disable Ambient mode Programmatically - java

I have in the past developed some small Android Apps, and have recently gotten an LG G Watch, and absolutely love it.
Right now, the only issue with the device is that it lasts about a day and a half in ambient mode.
What I am looking to be able to do is through software, enable and disable the ambient mode on the device. In doing this, we will be able to turn it off at specific times, i.e. at night.
The advantage of being able to do this is both save the display, and by turning ambient mode off at night, I only need to charge the device every other day, but it is just an inconvenience to enable / disable every day.
I have the Java / Android experience to build the app, but the question I have is essentially the whole thing:
How can I, in code, enable and disable ambient mode?
Is this possible? I spent some time googling, and been unable to find an answer. Has anyone used the wearable API? And is there anything in it that would allow something like this?

It is not possible to disable ambient mode programatically. However, you don't need to do what you are describing. The device detects that is not worn and after 30 minutes it will turn the screen off completely, including turning off ambient mode.

If you are a AOSP programmer, modify AmbientService to call finish() from AmbientDream, if you are a app programmer, sorry there's no API for what you want.

Related

Why? Status: App not accepted into Wear OS on Google Play

So I been trying to get my first Wear Os watch face published But when I submit I keep it keeps getting rejected. I only lightly changed the Sample Android studio provides nothing much changed but the background and the way the hands move.
I keep getting this.
I really do not know why it keeps getting rejected. I make sure it works for both square and round wear OS.
I keep getting this message
Step 1: Fix the eligibility issue with your app
During review, we detected the following eligibility issue and were unable to accept your app for Wear OS:
The basic functionality of your app does not work as described in App Bundle
Wear OS functionality should work as expected or as described in the app's Google Play Store listing. Please make sure to test your app on a variety of Wear OS devices and configurations.
For example, Hours and Minutes hands are not placed in the center of the watch face on Square Device. as shown/described on the store listing.
I really don't know what to do because I have appealed twice. I asked is it because I am moving the arrows differently. I get the same generic response.
Thank you all for the questions and comments.
I did test the application on sq watches.
And same results I got.
Things started changing when I added a circle into the middle of the screen and that ended up being allowed as center. I have no idea why that would matter I knew it was already centered.
Thanks all.

Get the number of "tap" on a locked smartwatch screen

I'm doing a school project as a team, but none of us have never developed or even worn smartwatches.
We want to get the number of "tap" on a smartwatch's locked screen but we don't find out if that's possible.
Do you know a way to get the number of "tap" on a locked smartwatch screen?
If this is not possible, can we display a constant notification and retrieve the number of "tap" on this notification?
I'm using a Moto 360 with Android 6.0.1 and Android Wear 1.4.0.
Thank you in advance.
I would advise everyone on the team get a chance to the use watch just to understand the user experience. Watches are very battery limited devices and will always try to go into low power mode as often as possible.
Do you know a way to get the number of "tap" on a locked smartwatch screen?
Tapping normally wakes up watch, either from full screen off or lower power ambient mode. If you want to capture taps/button press you can create a watch app which when active will receive taps/button presses. I'm not quite sure if watch face can capture taps, and if it did it my guess would be after the watch face is fully on, but that would be another place to look.
If this is not possible, can we display a constant notification and retrieve the number of "tap" on this notification?
Custom watch face can allow display of custom content. Alternatively as a watch app you can show what you want.
Additional Comments
The Moto 360 came out in 2014 and was one of first Android Wear watches available. The latest code samples & codelabs from Google are for Wear OS 2.0. You can look back in the commit history for old versions of samples which may be more compatible with Android Wear 1.4
Also from this Android Wear Notice May 2015 always on apps became possible so that might work for your project/use case.

Click on an x and y position in another android application

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

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

SlidingTab on Lock Screen vibrates when unlocking - regardless of the global settings about haptic feedback

When unlocking my android 2.3.3 phone at the simple lock screen it vibrates once the slider is touched and a second time a little longer when the slider has been pulled completely to the other side.
I found it a little annoying and so I thought I could somehow switch it off in the settings as I can switch off any other vibration.
There are actually two categories which might make sense in this case:
1) Sound Settings/General/Vibrate with the individual settings: (always, never, only in silent mode, only when not in silent mode)
2) Sound Settings/Feedback/Haptic Feedback (on/off)
I had to find out, that none of these settings have an impact on the unlocking action mentioned above.
So I googled and found some comments about the fact, that the vibration cannot be switched off easily in the settings.
e.g.
http://code.google.com/p/android/issues/detail?id=34040
Now I got curious and I tried to dive in a little deeper into the android sources and found the source for the slider here: https://github.com/android/platform_frameworks_base/blob/master/core/java/com/android/internal/widget/SlidingTab.java
see:
vibrate(VIBRATE_SHORT);
and:
vibrate(VIBRATE_LONG);
It seems to me that the vibrate action is called regardless of any settings.
Now I have some questions:
Shouldn't the vibration for unlocking consider the settings from either 1) or 2) above?
How would this be added to the source code and how would this change be applied to the android source repository so that some time later this could be migrated into the next android (if the sliding tab is used there at all)
Would it be possible to update the file SlidingTab.java seperately and test it on my rooted device or would it be necessary to do the complete make for the whole android system and flash my mobile phone with the new system in order to see if it works?
I have found other mobile phones with the same slider and no vibration when unlocking. I am clueless how this can be after I found the prove that it is not able to switch off the vibration in the source code.
thank you for sharing your knowledge with me
Nils
It may be consider or may not.
Not sure here.
If you need to change lock screen at all you can find various implementation. If you need to change default lock screen you need to build entire system.
Every companies customise Android for the phones. Therefore some sliders may have no vibration. Or the phone may have no hardware for it.

Categories

Resources