Skip to content

Instantly share code, notes, and snippets.

@molidev8
Created June 9, 2022 14:05
Show Gist options
  • Save molidev8/d8021cc4ef2a17c244278e990c494db9 to your computer and use it in GitHub Desktop.
Save molidev8/d8021cc4ef2a17c244278e990c494db9 to your computer and use it in GitHub Desktop.
A function to act as a publisher in Nearby Share
fun startAdvertising() {
val advertisingOptions =
AdvertisingOptions.Builder().setStrategy(Strategy.P2P_POINT_TO_POINT).build()
client.startAdvertising(
android.os.Build.MODEL, SERVICE_ID, ConnectingProcessCallback(), advertisingOptions
)
.addOnSuccessListener {
Log.d(GENERAL, "advertising...")
}
.addOnFailureListener {
Log.d(GENERAL, "failure advertising...")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment