Change Watchface Brightness in Android Wear - wear-os

How can I change brightness of watch using Android Wear SDK (in my code) while my watch-face is running.
I want to keep brightness lower than the lowest level of Android Wear brightness settings.

I found a solution, yes it's vivid! But it's not working in ambient mode on most watches:
private void updateBrightness() {
android.provider.Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
if (!mAmbient)
android.provider.Settings.System.putInt(getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS, getBrightness());
else
android.provider.Settings.System.putInt(getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS, getAmbientBrightness());
}

Related

Display app icon on top of all window in android wear?

I am developing an wear app, i want the app icon to be display on top of window
above the watch face. I have tried using WindowManager but failed to get the
result.
WindowManager.LayoutParams params=new
WindowManager.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
params.gravity= Gravity.CENTER|Gravity.CENTER;
params.x=160;
params.y=160;
windowManager=(WindowManager)getSystemService(WINDOW_SERVICE);
windowManager.addView(mfloatview,params);
my question is it possible to add an floating app icon in android wear?
I'm not sure if this feature (Display app icon on top of all window) is available. But you can try checking the documentation - Watch Face Complications.
A complication is any feature in a watch face that displays more than hours and minutes. For example, a battery indicator is a complication. The Complications API is for both watch faces and data provider apps.
Just like this:
Since you are using Android Wear 2.0, Complication API will be available for use.
Hope this helps.
I tried this one and works for android wear also...
apply same concept to wear, it works
http://www.androidhive.info/2016/11/android-floating-widget-like-facebook-chat-head/

Android Wear long running app - save battery

I'm developing a map application for Android Wear with the possibility to log routes with the GPS. Since logging a route can go on for a while I would like to save as much battery as possible while logging but still, I need to show the current speed and distance to the user. My idea is to use the KeepScreenOn flag to stay in the current app and then lower the brightness of the screen to a minimum when logging.
The problem is I don't know if that's good enough for saving battery or if you guys have a better idea? Is it possible to have ambient mode for an app that is not a watch face?

Wrist gesture detection on Android Wear based smartwatches: is it possible?

Does anyone have any information to share regarding gesture detection using wrist movements (in contrast to swipe movements on the touchscreen) with Android Wear?
Is there official support for this in the API? If not, do you think this can be enabled via custom ROMs?
Considering Android Wear is... well, Android, and Android has all the API functions to get data from the accelerometer of an Android based smartphone (and lots of helpful development sources), I assume it wouldn't be too hard? Or am I overlooking something?
Someone said the following at http://forum.xda-developers.com/android-wear/development/gesture-detection-using-wrist-t2936656
Use asus remote camera app for android wear. If you twist your watch
it will take a picture with your smartphone camera!
To which I replied:
So wrist gesture detection is perfectly possible it seems? But can you
or anyone else give me some additional background about Android Wear:
Should I see Android Wear as a simple extension of the Android API?
By which I mean: can I utilise all the Android API functions related
to interpreting smartphone/tablet sensor data, provided the smartwatch
has that sensor? (e.g accelerometer)
Since I was looking in this
particular section related to Wearables (Remove the spaces: developer
. android . com/training/building-wearables.html ) and I couldn't find
any information about wrist gesture detection.
Is that simply because
everything else from the Android API is automatically also applicable
to smartwatch development?
(As one can tell, I'm quite new to mobile development.)
So far no answer. I'm now asking here in hope I get an answer...
Wrist gestures were added in Android Wear 5.1 however at the time of this response, Android Wear 5.1 is only available on the LG Watch Urbane. This update is expected on other Wear devices in the upcoming weeks
Two common wrist gestures are interpretted by the system as swipe up/down. You change the speed of the flick either away or towards you.
If you flick your wrist away from you quickly, then back slowly that will cause a scroll down.
If you turn your wrist slowly away then flick it quickly back towards you, this will scroll up.
You can see the wrist gestures in action here - https://www.youtube.com/watch?t=14&v=_R0qbB4hVbU
You can use the IBM Wearables SDK for Android
to record and recognise all kinds of gestures not only wrist
for more info:
https://github.com/ibm-wearables-sdk-for-mobile/ibm-wearables-android-sdk
Disclaimer: I am the author of the articles/code described below.
I just created an Accessibility Service that does exactly what you are describing: it gives you the ability to completely control your smartwatch using wrist gestures.
I created it for my own use (I can only use one of my hands, the one in which I wear the watch) and I can fully control it using wrist gestures.
https://jsalatas.ictpro.gr/handsfree-wear-a-wrist-gesture-input-method-for-android-based-smartwatches/
notice that in the current phase I'm not sure if the model that recognizes the wrist gestures can generalize or if it just recognizes my wrist gestures only.

How to get TouchEvent on Windows desktop for OpenFL app?

I'm on a touch enabled Windows machine compiling OpenFL. I'm compiling to the Windows/C++ target using OpenFL and Haxe 3.
I cannot get touch events to work. Here's where I'm adding them:
private function onAdded(e:Event):Void
{
stage.addEventListener(Event.RESIZE, resize);
resize(null);
init();
addEventListener( Event.ENTER_FRAME, onEnterFrame);
addEventListener( TouchEvent.TOUCH_BEGIN, onTouchBegin );
stage.addEventListener( TouchEvent.TOUCH_MOVE, onTouchMove );
stage.addEventListener( TouchEvent.TOUCH_END, onTouchEnd );
}
My enterFrame() is getting invoked just fine. No touch (or using mouse) triggers the handlers. Is this a Windows desktop limitation? Would this work once I put on iOS and Android? Why not? Is this a NME/OpenFL bug?
You can use mouse in place of touch on windows for now with the 1.1 update, until full support for multitouch is implemented. Works fine for iOS and Android etc.
singmajesty on the forum
Try it the other way, use a MouseEvent to handle both mouse and touch input on a desktop.
We just (in OpenFL 1.1, released this week) migrated to SDL2 for the backend for Windows. This actually has support for real touch events, so in the future I expect to see multi-touch support for the desktop. It just was not that long ago that this was only a thing for mobile devices smiling
So if you don't need to track individual touch points separately, mouse events should do it for you today. Otherwise, we're positioned now to be able to wire support for this in the not-too-distant future smiling

Can MPMoviePlayerController have volume programmatically adjusted?

I have this MPMovePlayerController and a custom slider (which is not quite a slider, but it has the same purpose). Considering that my "slider" can return any float value I need, how can I change the volume of the played movie?
So far I'v tried hacking MPVolumeView to programmatically set a value, w/o success.
iOS 3.0 - 7.0
Turns out that
[[MPMusicPlayerController applicationMusicPlayer] setVolume:<insert float here>];
works for any sound in the app, even the MPMoviePlayerController, if it's using the main Audio Session. O, it works only on the device, not the simulator. More info here:
https://developer.apple.com/documentation/mediaplayer/mpmusicplayercontroller?language=objc
Update
Volume is deprecated in iOS 7.0.
"To provide UI for adjusting system playback volume, use the MPVolumeView class, which provides media playback controls that iOS users expect and whose appearance you can customize." Deprecated MPMusicPlayerController Volume Method
[[MPMusicPlayerController applicationMusicPlayer] setVolume:<insert float here>];
Will change the device's volume, not the media player's so any other audio or video streams are also affected.

Resources