B4A Library WatchFace Library

Peter Simpson

Expert
Licensed User
Longtime User
Hello All,
I created an Android Wear watch face and then decided to add a user configuration parameters screen (settings screen). Android Wear supplies an easy way for your users to open an activity which would be for example your watch face settings screen, just hold your finger on your watch face for about one second and the setting screen will open.

If implemented correctly, a small settings icon will appear below your watch face in the preview screen.

Please note, I personally use StateManager to store and restore the user setting.

Example below, replace com.example.watchface with your actual package name followed by a dot then your settings activity name.
B4X:
#Region Configuration Activities

AddServiceText(TixWatchFace,
    android:name =".DigitalWatchFaceService" ... />

    <!-- wearable configuration activity -->
    <meta-data
        android:name = "com.google.android.wearable.watchface.wearableConfigurationAction"
        android:value = "com.example.watchface.configuration" />
)

AddActivityText(Configuration,
    android:name=".DigitalWatchFaceWearableConfigActivity"
    android:label="@string/digital_config_name">

    <intent-filter>
        <action android:name = "com.example.watchface.configuration" />
        <category android:name = "com.google.android.wearable.watchface.category.WEARABLE_CONFIGURATION" />
        <category android:name = "android.intent.category.DEFAULT" />
    </intent-filter>
)

#End Region


If you are going to upload your watch face onto the Android Wear store, you should also add the following code to your manifest file.
B4X:
#Region Android Play store options

'Let Android Play Store know it's for Android Wear Only (a watch)
AddManifestText(
    package="com.simplysoftware.tixwatchface"
        xmlns:android="http://schemas.android.com/apk/res/android">
        <uses-feature android:name="android.hardware.type.watch"/>
)


'Let Android Play Store know it's a stand alone app
AddApplicationText(
    <meta-data
        android:name="com.google.android.wearable.standalone"
        android:value="true" />
)

#End Region

Enjoy...
 
Last edited:

ilan

Expert
Licensed User
Longtime User
i wanted for a long time to create smartwatch apps using b4a and i ordered yesterday a new smartwatch because i knew we have a way to do it with b4a using this library. unfortunately, i did not notice that the watch i was ordering has not android wear installed.

its the Samsung gear s3 frontier and it is using Tizen OS. so i guess i will need to learn Tizen Studio.
Any chance there will be a possibility using b4x to create apps for Samsung watches?
 

ilan

Expert
Licensed User
Longtime User
Why not just send the watch back, I presume that you purchased it from new????????????

yes, of course, its new but i like Samsung and i like a lot the design of this watch so i will keep it and learn Tizen Studio. You can code in C,C++ and also in Html, JS, CSS.
 

corwin42

Expert
Licensed User
Longtime User
@corwin42 , the library needs to be updated in order to work with AndroidX sdk. The update shouldn't be too complicated. The base class name should be updated and the depends on list.
I will have a look at it in the next days.
 

corwin42

Expert
Licensed User
Longtime User
@corwin42 , the library needs to be updated in order to work with AndroidX sdk. The update shouldn't be too complicated. The base class name should be updated and the depends on list.

Seems to be not so easy.

As I understand correctly, there is no AndroidX version of com.google.android.support:wearable:2.5.0 library.
So even in AndroidStudio you add the following line to compile AndroidWear projects:
Java:
    implementation 'androidx.wear:wear:1.0.0'
    implementation 'com.google.android.support:wearable:2.5.0'
    compileOnly 'com.google.android.wearable:wearable:2.5.0'

So I always get the following error output:
 

corwin42

Expert
Licensed User
Longtime User
First post updated with library version 2.0 which is compatible with AndroidX.

Be aware that you need to add the dependencies for the library in the watchface code. See first post.
 

Peter Simpson

Expert
Licensed User
Longtime User
First post updated with library version 2.0 which is compatible with AndroidX.

Hello @corwin42
I've just updated all my personal watch faces and your updates are working 100% perfect. This also means that I can now finally delete my old SDK folder as I was only keeping that folder as it was the only way that I could update my wear watch faces.

Thank you ???
 

Watchkido1

Active Member
Licensed User
Longtime User
It makes you cry .....
I've been sitting here for two days now, installing new, copying, extracting with 7-Zip ... 2 times I did the reinstallation according to the specifications ...
Nothing achieved ...
I just can't get this error message away.
I'm totally desperate.
I just want to make a watchface ...


 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…