Created
November 5, 2018 02:02
-
-
Save ricardoogliari/fa70b05f9c902d6ea4e24622fbe6804b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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