0
Good morning ! How do I share a link from my app with a contact in Whatsapp ? Searching on the internet I was able to form this code (it is without successful tests because I’m still just testing it) that when recording an activity in firebase I open a library full of apps to share a link, but so far I can only share the text: "User x has created a new activity, what I’d like is for this message to have a link that directs the person directly to the profile or to any screen of my app for example. Follows code (from Activity’s Website) that shares the text cited above:
public void compartilharAtividade(){
    Branch branch = Branch.getInstance();
    //Uri mainUri = getActivity().getIntent().getData();
    Intent share = new Intent(android.content.Intent.ACTION_SEND);
    share.setType("text/plain");
    share.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    share.putExtra(Intent.EXTRA_SUBJECT, "Teste de compartilhamento APP");
    share.putExtra(Intent.EXTRA_TEXT, "O usuario "+ nomeUsuario + " criou uma nova atividade! Teste de Link: "+ branch);
    //share.putExtra(Intent.EXTRA_PACKAGE_NAME, "com.ramattecgmail.rafah.studying");
    startActivity(Intent.createChooser(share, "Teste de compartilhamento"));
}
in Main Activity I call the branch this way:
@Override
public void onStart() {
    super.onStart();
    Branch branch = Branch.getInstance();
    branch.initSession(new Branch.BranchUniversalReferralInitListener() {
        @Override
        public void onInitFinished(BranchUniversalObject branchUniversalObject, LinkProperties linkProperties, BranchError error) {
            if (error == null) {
                // params are the deep linked params associated with the link that the user clicked -> was re-directed to this app
                // params will be empty if no data found
                // ... insert custom logic here ...
            } else {
                Log.i("MyApp", error.getMessage());
            }
        }
    }, this.getIntent().getData(), this);
}
@Override
public void onNewIntent(Intent intent) {
    this.setIntent(intent);
}
In short, I need my app to send the Uri itself, or at least recover this Uri that I can’t even do in Main Activity... Thanks in advance!
Do you have any specific link ?
– Dev
Actually not exactly, it’s the first time I’m messing with sharing like this, so I may be wrong about some things, but I think it should work as follows: send a message to the person with a link that when they click will direct to the app in the profile Activity that will load the data of the user I pass in the message, or in this case with a link of the activity that was opened... briefly, by clicking on the link of the message it opens my app.
– Eduardo Rafael Moraes
if you send a link it will redirect to a web page, not to your app
– Dev
So how do I direct you to my app? It’s possible ?
– Eduardo Rafael Moraes
It’s possible, you’ll have a little work hehe, I’ll do a quick research and I’ll be right back to help you
– Dev