示例#1
0
  @Override
  public void onCreate() {
    super.onCreate();

    // First, we initialize the Hub singleton with an application identifier.
    Hub hub = Hub.getInstance();
    if (!hub.init(this, getPackageName())) {
      showToast("Couldn't initialize Hub");
      stopSelf();
      return;
    }

    // Next, register for DeviceListener callbacks.
    hub.addListener(mListener);

    // Finally, scan for Myo devices and connect to the first one found.
    hub.pairWithAnyMyo();
  }
示例#2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.counter_activity);
    tvCounter = (TextView) findViewById(R.id.tvCounter);
    cflCounter = (CounterFrameLayout) findViewById(R.id.cflCounter);
    tvCounter.setText("" + mRepCounter);

    mHub = Hub.getInstance();
    if (!mHub.init(this, getPackageName())) {
      // We can't do anything with the Myo device if the Hub can't be initialized, so exit.
      Toast.makeText(this, "Couldn't initialize Hub", Toast.LENGTH_SHORT).show();
      finish();
      return;
    }

    mTextToSpeech =
        new TextToSpeech(
            getApplicationContext(),
            new TextToSpeech.OnInitListener() {
              @Override
              public void onInit(int status) {}
            });
    mTextToSpeech.setLanguage(Locale.US);

    Intent intent = getIntent();
    mWorkout = intent.getParcelableExtra(Workout.TAG);

    mHub.setLockingPolicy(Hub.LockingPolicy.NONE);
    mHub.addListener(mWorkout);

    float peak = intent.getFloatExtra(CalibrationActivity.KEY_PEAK, 0);
    float dip = intent.getFloatExtra(CalibrationActivity.KEY_DIP, 0);
    mWorkout.setRange(dip, peak);
    mWorkout.setCallback(this);

    Log.e(TAG, "PEAK: " + dip);
    Log.e(TAG, "DIP: " + peak);
  }