fbpx

Our Story

Enterprise solutions to empower people.
Company was established in the year 2012. Provide high quality cost effective services to the community and businesses. Goldenmace is a company with young, energetic, curious and committed minds who are excited about solving complex business problems, ethically. We build long term relationships and provide quality products and services that will exceed the expectations of all our customers. We deliver secure, reliable and scalable applications that help businesses excel in today’s rapidly evolving economy.

Working Hours

Monday to Saturday ................. 09:00 - 18:00

Sunday ......................... CLOSED

 

Getting Started with Wear OS 2.0 App Development.

Getting Started with Wear OS 2.0 App Development.

                            Google introduced Wear OS version 2.0 in 2017. There are so many wear applications are publishing on play store. Google Introduces too many features for wear OS in all Google I/O events.There are many companies comes to serve the wear OS like Asus, Motorola, Armani, Misfit, Samsung, Fossil, Sony and so on. In this blog we will take a look at creating our first Google wear app , which leads to developers for creates their initiate app.

 

                          Before start this blog, We must know about the Wear OS features. There are three features in which Android developers can build their apps and publish to playstore.

                       – Watchfaces

                       – Complications Data Providers

                       – Wear Applications

 

                      Watchfaces are the virtual dials which shows local time and date.Complications Data Providers are data providers which lets you display the additional information like Step Counter, Weather forecast, details about next meeting and much more.While Wear Applications lets user to communicate between mobile to wear and wear to mobile.

 

                     In this blog we will learn how wearable apps are made. By the way I have a Misfit-Vapor watch for testing. It has API level 8.0 so we’ll be using minimum API 23 in this tutorial. We will create a wearable app which have circular list view in which there are several items. Whenever particular item selected , app background color will be changed.

Getting Started :

                     We’ll begin by starting a new project in which phone and tablet checkbox and wear checkbox both must be checked. Wear API is set to minimum 23 API version.

 

 

There are two packages in studio “Mobile” and “Wear” , In which Wear module included in Mobile package.

1. mobile – our phone and tablet app

2. wear – our watch app

You can see below folder structure.

 

 

 

 

    

Pay special attention to the following two files:

  1. wear_activity_home_rect.xml – is our user interface for the watches that use a Rectangle screen.
  2. wear_activity_home_round.xml – is our user interface for the watches that use a Round screen.

 

activity_main.xml

<android.support.wearable.view.WatchViewStub xmlns:android="http://schemas.android.com/apk/res/android
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/watch_view_stub"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:rectLayout="@layout/wear_activity_home_square"
    app:roundLayout="@layout/wear_activity_home_round"
    tools:deviceIds="wear"/>

wear_activity_home_round.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.wear.widget.WearableRecyclerView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/recycler_launcher_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="vertical" />

wear_activity_home_square.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.wear.widget.WearableRecyclerView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/recycler_launcher_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="vertical">

MainActivity.kt

import android.graphics.Color;
import android.os.Bundle;
import android.support.wear.widget.WearableLinearLayoutManager;
import android.support.wear.widget.WearableRecyclerView;
import android.support.wearable.activity.WearableActivity;
import android.support.wearable.view.WatchViewStub;

class MainActivity : WearableActivity() {

    private var recycler_launcher_view: WearableRecyclerView? = null
    private var customRecyclerAdapter: CustomRecyclerAdapter? = null
    private var customScrollingLayoutCallback: CustomScrollingLayoutCallback? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        setAmbientEnabled()
        val stub = findViewById(R.id.watch_view_stub)
        stub.setOnLayoutInflatedListener { stub ->
                recycler_launcher_view = stub.findViewById(R.id.recycler_launcher_view)
                recycler_launcher_view!!.isEdgeItemsCenteringEnabled = true
                customScrollingLayoutCallback = new CustomScrollingLayoutCallback();
                val wearableLinearLayoutManager = WearableLinearLayoutManager(this@MainActivity, customScrollingLayoutCallback)
                recycler_launcher_view!!.layoutManager = wearableLinearLayoutManager
                recycler_launcher_view!!.isCircularScrollingGestureEnabled = true
                recycler_launcher_view!!.bezelFraction = 0.5f
                recycler_launcher_view!!.scrollDegreesPerScreen = 90f
                customRecyclerAdapter = CustomRecyclerAdapter()
                 customRecyclerAdapter!!.setOnItemSelectListener(object : CustomRecyclerAdapter.OnItemClick {

                    override fun onItemColorSelect(colorCode: String) {(String colorCode) {
                        recycler_launcher_view!!.setBackgroundColor(Color.parseColor(colorCode))
                    }
                })
                recycler_launcher_view!!.adapter = customRecyclerAdapter
            }
    }
}

The source code for this app can be found here. Go ahead and fork the repository and try adding additional.
 

Comment

Sorry, the comment form is closed at this time.