Android Open Source - android-wear-go-walk Wear Activity






From Project

Back to project page android-wear-go-walk.

License

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.

Java Source Code

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);
    }


}




Java Source Code List

com.beltranfebrer.gowalk2.ApplicationTest.java
com.beltranfebrer.gowalk2.BootCompletedIntentReceiver.java
com.beltranfebrer.gowalk2.MainActivity.java
com.beltranfebrer.gowalk2.StepChecker.java
com.beltranfebrer.gowalk2.WearActivity.java
com.beltranfebrer.gowalk2.WearService.java