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:
From the Project Navigator window, open the
MobileActivity.java
file.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);
Next, we need to set up an
onClickListener
method...