4

Does anyone know what the scan duration is for the google nearby messages api and also the time gap between each scan? Just out of curiosity as the document does not state anything about this.

Mr.Noob
  • 1,005
  • 3
  • 24
  • 58

2 Answers2

2

When you publish() or subscribe(), there is a TTL that depends on the strategy you pass in. The strategy is part of the SubscribeOptions or PublishOptions objects that you can choose to pass in. You can set the TTL to whatever you like, including TTL_SECONDS_INFINITE. If you don't pass one in, it will use the default strategy which has a TTL of 300 seconds.

See the reference for the Strategy class.

MahlerFive
  • 5,159
  • 5
  • 30
  • 40
  • TTL_SECONDS_INFINITE is not working for me, when I exchange to another value everything works again – Marabita Apr 02 '20 at 00:53
0
private static final Strategy PUB_SUB_STRATEGY = new Strategy.Builder().setTtlSeconds(10)
  .setDistanceType(Strategy.DISTANCE_TYPE_EARSHOT)
  .setDiscoveryMode(Strategy.DISCOVERY_MODE_BROADCAST).build();

You can pass a time in millisecond after that time this on Expire method call . you can recall publish method to again publish/subscribe

@Override
public void onExpired() {
  super.onExpired();
  getLog("No longer publishing");
  Toast.makeText(activity, "FailonExpired", Toast.LENGTH_LONG).show();
  publish();
}
}).build();
ochs.tobi
  • 3,214
  • 7
  • 31
  • 52
Amit Nain
  • 1
  • 1