官术网_书友最值得收藏!

Creating your first Wear project

Click on the Start a new Android Studio project option in the Android Studio window. You will be prompted by another window with project details.

The following screenshot shows the window that allows users to configure their project details, such as project name, Package name, and whether the project needs native C++ support:

You can name your project as you wish. After you have chosen your project name and your project local system location, you can press the Next button in the window, which brings up another window with a few configuration queries, as shown in the following screenshot:

In this window, you can choose to write a standalone Wear application if you uncheck the Phone and Tablet option. In this way, you will see only Wear application templates:

Now, Android Studio templates prompt only Android Wear activity templates with the following set of options:

  • Add No Activity
  • Always On Wear Activity
  • Blank Wear Activity
  • Display Notification
  • Google Maps Wear Activity
  • Watch Face

The activity template chooser helps you to access the default boilerplate codes, which are already templatized and can be used directly in projects:

To create the first project, we will choose Blank Wear Activity and click on the Next button in the window. Android Studio will prompt another window for creating the name of the activity and layout file. In this template, the two form factors of Android Wearable devices, which are mostly round and square shapes, are prepopulated with the boilerplate code stub:

When your project is ready to be created, click on the Finish button. After clicking on Finish, Android Studio will take a few moments to create the project for us.

Way to go! You have now created a working boilerplate code for the Android Wear standalone application without the phone companion application. When successfully created, you will see the following files and codes added to your project by default:

If your SDK is not updated with API level 25, you might see the Wear option in the Android Studio project creating prompts with Android Wear support library 1.x; you can update this in the Wear module Gradle file with the following dependency:

compile 'com.google.android.support:wearable:2.0.0'
主站蜘蛛池模板: 喀喇沁旗| 兴隆县| 融水| 麻栗坡县| 灵石县| 枣强县| 离岛区| 绥滨县| 沈丘县| 双桥区| 河北区| 仙居县| 高平市| 镇康县| 普兰店市| 许昌市| 龙胜| 台南县| 南昌市| 莎车县| 临猗县| 崇阳县| 夏邑县| 东山县| 岐山县| 涟源市| 宁津县| 蓬安县| 藁城市| 库尔勒市| 剑川县| 汝城县| 宜阳县| 永城市| 麦盖提县| 定陶县| 仲巴县| 休宁县| 陵川县| 新巴尔虎左旗| 永清县|