Google Nearby Connections - Timed Advertising

53 views Asked by At

I am using google Nearby connections to create a P2P network using the Star strategy and I was wondering if it is possible to set the advertising device to stop advertising after a 5 minutes.

1

There are 1 answers

0
afarre On

You could set up a thread, with a timer. If the timer reaches 0, and you are advertising, then call the corresponding stopAdvertising() method.

Besides this, keep in mind that the user should be aware when the device is advertising via an icon or a special screen. This is stated in this video (they talk about nearby messages, rather than connections, but the best practices still apply).

What I mean, is that it would be odd to have the user waiting for 5 minutes in the same screen while advertising. Most likely he quits before the 5 minute window has passed, at which point you must also stop advertising. If you think in your application the user might stay in the advertising screen for over 5 minutes, then use the counter in a thread.