Skip to content

Instantly share code, notes, and snippets.

@ricardoogliari
Created November 5, 2018 02:17
Show Gist options
  • Save ricardoogliari/3c7c81be52b8c87bbaa6307d74d251e6 to your computer and use it in GitHub Desktop.
Save ricardoogliari/3c7c81be52b8c87bbaa6307d74d251e6 to your computer and use it in GitHub Desktop.
private val PUB_SUB_STRATEGY = Strategy.Builder().setTtlSeconds(Strategy.TTL_SECONDS_MAX).build()
private val PUB_OPTIONS = PublishOptions.Builder()
.setStrategy(PUB_SUB_STRATEGY)
.setCallback(object : PublishCallback() {
override fun onExpired() {
"Experid message".toast(this@MainActivityK);
}
})
.build()
fun share(view: View) {
val buffer = StringBuffer()
buffer.append(edtFacebook.text.toString() + " ")
buffer.append(edtTwitter.text.toString() + " ")
buffer.append(edtLinkedin.text.toString() + " ")
buffer.append(edtPhoto.text)
message = Message(buffer.toString().toByteArray())
Nearby.getMessagesClient(this)
.publish(message!!, PUB_OPTIONS)
.addOnSuccessListener(this) { aVoid -> Log.e(TAG, "sucesso: $aVoid") }
.addOnFailureListener(this) { e -> Log.e(TAG, "sucesso: $e.localizedMessage") }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment