Book Image

Android Wearable Programming

By : Steven F. Daniel
Book Image

Android Wearable Programming

By: Steven F. Daniel

Overview of this book

Table of Contents (14 chapters)
Android Wearable Programming
Credits
About the Authors
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Sending messages to the Android wearable


In this section, we will be taking a look at the steps involved in sending a message to your Android wearable device. This process is quite simple, and our next step is to write the code that will communicate between our Android wearable and the handheld device:

  1. From the Project Navigator window, open the MobileActivity.java file.

  2. Next, modify the onCreate(Bundle savedInstanceState) method and enter the code highlighted as follows:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_mobile);
    
      // Get a pointer to our buttons and textField
      final Button mSendMessageButton = (Button) 
      findViewById(R.id.send_message_button);
      final EditText mSendMessageInput = (EditText) 
      findViewById(R.id.send_message_input);
    
      // Set up our hint message for our Text Field
      mSendMessageInput.setHint(R.string.send_message_text);
    
  3. Next, we need to set up an onClickListener method...