package com.tk20.tk20android.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.EditText;

import com.tk20.tk20android.R;

public class MainActivity extends Activity {
  private static final String ASSET_HTML_PATH = "";

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final WebView wv = (WebView) findViewById(R.id.webView);
    wv.getSettings().setJavaScriptEnabled(true);
    wv.setWebViewClient(new WebViewClient() {
      @Override
      public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
      }
    });
    wv.loadUrl("file:///android_asset/www/html/index.html");
    final EditText et = (EditText) findViewById(R.id.ipEdit);

    findViewById(R.id.ipButton).setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        wv.loadUrl("javascript:setIp(\"" + et.getText().toString() + "\");");
      }
    });
  }
}

@@ -33,16 +33,283 @@
 ivity;%0A%0A
+import com.google.android.gms.common.ConnectionResult;%0Aimport com.google.android.gms.common.api.GoogleApiClient;%0Aimport com.google.android.gms.wearable.MessageApi;%0Aimport com.google.android.gms.wearable.MessageEvent;%0Aimport com.google.android.gms.wearable.Wearable;%0A%0A
 import a
@@ -329,16 +329,16 @@
 tivity;%0A
-
 import a
@@ -355,16 +355,41 @@
 Bundle;%0A
+import android.util.Xml;%0A
 import a
@@ -505,16 +505,45 @@
 ditText;
+%0Aimport android.widget.Toast;
 %0A%0Aimport
@@ -664,16 +664,99 @@
 TH = %22%22;
+%0A  private MessageApi.MessageListener mListener;%0A  private GoogleApiClient mClient;
 %0A%0A  @Ove
@@ -1552,22 +1552,1257 @@
       %7D%0A
-
     %7D);
+%0A%0A    mClient = new GoogleApiClient.Builder(this)%0A        .addApi(Wearable.API)%0A        .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() %7B%0A          //TODO: Do something.%0A          @Override%0A          public void onConnected(Bundle bundle) %7B%0A%0A          %7D%0A%0A          @Override%0A          public void onConnectionSuspended(int i) %7B%0A%0A          %7D%0A        %7D)%0A        .addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() %7B%0A          @Override%0A          public void onConnectionFailed(ConnectionResult connectionResult) %7B%0A%0A          %7D%0A        %7D)%0A        .build();%0A%0A    mListener  = new MessageApi.MessageListener() %7B%0A      @Override%0A      public void onMessageReceived(MessageEvent messageEvent) %7B%0A        Toast.makeText(MainActivity.this, new String(messageEvent.getData()),Toast.LENGTH_LONG)%0A            .show();%0A      %7D%0A    %7D;%0A%0A    Wearable.MessageApi.addListener(mClient, mListener);%0A  %7D%0A%0A  @Override%0A  protected void onStop() %7B%0A    super.onStop();%0A    mClient.disconnect();%0A  %7D%0A%0A  @Override%0A  protected void onStart() %7B%0A    super.onStart();%0A    mClient.connect();%0A  %7D%0A%0A  @Override%0A  protected void onDestroy() %7B%0A    super.onDestroy();%0A    Wearable.MessageApi.removeListener(mClient, mListener);
 %0A  %7D%0A%7D%0A

Add message reciever