B4A Library WatchFace Library

Peter Simpson

Expert
Licensed 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.
settings-icon.png
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
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?
 

DonManfred

Expert
Licensed User
This library does not depend on Tizen. Android wear and Tizen are not compatible. So i guess the answer is no.
 

ilan

Expert
Licensed 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.
 

Erel

Administrator
Staff member
Licensed 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.
 
Top