1

我是使用 pebble 的新手,我下载了他们在此处找到的海洋调查演示程序:https ://github.com/pebble/pebble-sdk-examples/tree/master/data-logging-demo/OceanSurveyDemo-Android

但是当我在 cloudpebble 上运行它和演示时,我看到的只是我的 android 应用程序上的黑屏。我想知道我是否还缺少其他任何东西来让数据记录在这里正常工作?我还尝试了他们的一些其他示例,如下所示:http: //developer.getpebble.com/guides/mobile-apps/android/android-datalogging/

我从 cloudpebble 上的日志记录会话中返回了 DATA_LOGGING_SUCCESS,但是当我使用他们提供的接收代码时,我的手机上什么也没有显示:

package com.getpebble.dataloggingtest;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.widget.TextView;

import com.getpebble.android.kit.PebbleKit;
import com.getpebble.android.kit.PebbleKit.PebbleDataLogReceiver;

import java.util.UUID;

/**
 * MainActivity class
 * Implements a PebbleDataLogReceiver to process received log data, 
 * as well as a finished session.
 */
public class MainActivity extends Activity {

  // Configuration
  private static final UUID WATCHAPP_UUID = UUID.fromString("12258306-6cff-4b67-8af3-6f14105e8d8f");
  private static final int DATA_LOG_TAG_COMPASS = 52;

  // App elements
  private PebbleDataLogReceiver dataloggingReceiver;
  private TextView textView;
  private StringBuilder resultBuilder = new StringBuilder();

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Setup TextView
    textView = (TextView)findViewById(R.id.text_view);
    textView.setText("Waiting for logging data...");
  }

  @Override
  protected void onResume() {
    super.onResume();

    // Define data reception behavior
    PebbleDataLogReceiver dataloggingReceiver = new PebbleDataLogReceiver(WATCHAPP_UUID) {

      @Override
      public void receiveData(Context context, UUID logUuid, Long timestamp, Long tag, int data) {
        // Check this is the compass headings log
        if(tag.intValue() == DATA_LOG_TAG_COMPASS) {
          // Get the compass value and append to result StringBuilder
          resultBuilder.append("Heading: " + data + " degrees");
          resultBuilder.append("\n");
        }
      }

      @Override
      public void onFinishSession(Context context, UUID logUuid, Long timestamp, Long tag) {
        super.onFinishSession(context, logUuid, timestamp, tag);

        // Display all compass headings received
        textView.setText("Session finished!\n" + "Results were: \n\n" + resultBuilder.toString());
      }

    };

    // Register DataLogging Receiver
    PebbleKit.registerDataLogReceiver(this, dataloggingReceiver);
  }

  @Override
  protected void onPause() {
    super.onPause();

    // Always unregister callbacks
    if(dataloggingReceiver != null) {
      unregisterReceiver(dataloggingReceiver);
    }
  }
}

我一定是误会了什么,但为什么我的手机没有收到任何数据?我在 Android Studio 中没有看到任何错误。

4

1 回答 1

0

我认为您没有收到任何数据,因为您需要按下手表上的按钮才能开始向手表发送数据。

于 2015-06-11T19:28:56.390 回答