I m developing an android application in which i want to able the user to publish a post with a social network or with email using DynamicLinks Firebase(If the application is already installed in the device the post activity will be opened directly,if not le link will open the play store page of the application).I followed these steps: 1/I have created a dynamilink in firebaseConsole and i have used "https://rc4vd.app.goo.gl/XktS" as shortlink 2/a button to send the dynamiclink, this is the code
btnShare.setOnClickListener(new View.OnClickListener() {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "I invite you to my challenge\n\n" + "https://rc4vd.app.goo.gl/XktS?d=" + databaseReference.getKey());
sendIntent.setType("text/plain");
startActivity(sendIntent);
}
3/At the reception of the dynamic link
FirebaseDynamicLinks.getInstance().getDynamicLink(getIntent()).addOnCompleteListener(new OnCompleteListener<PendingDynamicLinkData>() {
@Override
public void onComplete(@NonNull Task<PendingDynamicLinkData> task) {
Uri shortLink = null;
if (task.getResult() != null) {
// --> shortLink = task.getResult().getShortLink();
String postId = (shortLink.toString()).substring(shortLink.toString().indexOf("=")+1);
//[declare the intent]
Intent intent = new Intent(Home.this,MyPostPage.class);
//[Set intent extras]
intent.putExtra("ref", PostId);
//[start the activity with extras]
startActivity(intent);
}
}
}).addOnFailureListener(Home.this, new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.w(TAG, "getDynamicLink:onFailure", e);
}
});
the problem is "shortLink = task.getResult().getShortLink();" does not exist and i can only have the deepLink.I want to know if there is a way to have the short link and thanks