Skip to content

Instantly share code, notes, and snippets.

@ricardoogliari
Created November 5, 2018 02:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ricardoogliari/fa70b05f9c902d6ea4e24622fbe6804b to your computer and use it in GitHub Desktop.
Save ricardoogliari/fa70b05f9c902d6ea4e24622fbe6804b to your computer and use it in GitHub Desktop.
private final Strategy PUB_SUB_STRATEGY = new Strategy.Builder()
.setTtlSeconds(Strategy.TTL_SECONDS_MAX).build();
private final PublishOptions PUB_OPTIONS = new PublishOptions.Builder()
.setStrategy(PUB_SUB_STRATEGY)
.setCallback(new PublishCallback(){
@Override
public void onExpired() {
Toast.makeText(
MainActivity.this,
"Experid message",
Toast.LENGTH_LONG).show();
}
})
.build();
...
public void share(View view) {
StringBuffer buffer = new StringBuffer();
buffer.append(edtFacebook.getText() + " ");
buffer.append(edtTwitter.getText() + " ");
buffer.append(edtLinkedin.getText() + " ");
buffer.append(edtPhoto.getText());
message = new Message(buffer.toString().getBytes());
Nearby.getMessagesClient(this)
.publish(message, PUB_OPTIONS)
.addOnSuccessListener(this, new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Log.e(TAG, "sucesso: " + aVoid);
}
})
.addOnFailureListener(this, new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.e(TAG, "sucesso: " + e.getLocalizedMessage());
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment