Game Development Reference
In-Depth Information
Listing 11-6. round.xml
<?xml version= "1.0" encoding= "utf-8" ?>
<RelativeLayout xmlns:android= " http://schemas.android.com/apk/res/android "
xmlns:tools= " http://schemas.android.com/tools "
android:layout_width= "match_parent"
android:layout_height= "match_parent"
tools:context= "ch11.project.MainActivity"
tools:deviceIds= "wear_round" >
<TextView
android:id= "@+id/text"
android:layout_width= "wrap_content"
android:layout_height= "wrap_content"
android:layout_centerHorizontal= "true"
android:layout_centerVertical= "true"
android:text= "@string/hello_round" />
</RelativeLayout>
The last layout file to check is the string.xml file. Listing 11-7 shows the code for this file.
Listing 11-7. strings.xml
<?xml version= "1.0" encoding= "utf-8" ?>
<resources>
<string name= "app_name" >ch11.Project</string>
<string name= "hello_round" >My first Wear App</string>
<string name= "hello_square" >My first Wear App</string>
</resources>
This file, which is based on the type of wearable (such as rounded or rectangular), defines
the string to be displayed. In our case the string is “My First Wear App.”
Now that you've seen all the code you need for this simple wearable application, let's run
and test it.
Connecting an Android Device to the AVD Emulator
So far you've created the Android Wear emulator and the project that allows the emulator
to be connected to a real Android device. Remember that you will need an Android device
running on Android OS 4.3+ and above to connect to the Wear emulator.
Let's now see how to connect your Android smartphone or Tablet to the Wear emulator just
created in your project.
The first step is to install the “Android Wear App” from the Google Play store:
https://play.google.com/store/apps/details?id=com.google.android.wearable.app
(see Figure 11-19 )
 
Search WWH ::




Custom Search