0

我需要从已经注册的 eddystone 接近信标中获取附件和 placeid。是否有任何示例应用程序可用。

4

1 回答 1

1

查看 Nearby Messages API 中的入门部分:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ...
    mMessageListener = new MessageListener() {
        @Override
        public void onFound(Message message) {
            String messageAsString = new String(message.getContent());
            Log.d(TAG, "Found message: " + messageAsString);
        }

        @Override
        public void onLost(Message message) {
            String messageAsString = new String(message.getContent());
            Log.d(TAG, "Lost sight of message: " + messageAsString);
        }
    }

    ...

    // Subscribe to receive messages.
    private void subscribe() {
        Log.i(TAG, "Subscribing.");
        SubscribeOptions options = new SubscribeOptions.Builder()
            .setStrategy(Strategy.BLE_ONLY)
            .build();
        Nearby.Messages.subscribe(mGoogleApiClient, mMessageListener, options);
    }
}

https://developers.google.com/nearby/messages/android/get-beacon-messages

您将在对象“消息”的内容属性中找到附件。

于 2016-06-27T08:45:14.550 回答