Back to project page android-wear-go-walk.
The source code is released under:
MIT License
If you think the Android project android-wear-go-walk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.beltranfebrer.gowalk2; /*w ww .j a v a 2 s .c om*/ import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.os.Vibrator; import android.support.wearable.view.WatchViewStub; import android.widget.TextView; import com.google.android.gms.wearable.MessageApi; import com.google.android.gms.wearable.MessageEvent; public class WearActivity extends Activity { public static final String EXTRA_STEPS = "Steps"; private TextView mTextView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_wear); final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub); stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() { @Override public void onLayoutInflated(WatchViewStub stub) { mTextView = (TextView) stub.findViewById(R.id.text); Intent intent = getIntent(); float steps = intent.getFloatExtra(EXTRA_STEPS, 0); mTextView.setText("You walked " + String.valueOf(steps) + " steps\nin the last hour."); } }); Vibrator v = (Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE); v.vibrate(100); } }