1

I have a requirement of sending a url(myapp://app.myapp.com/data)with custom scheme through WhatsApp.But in WhatsApp its not showing custom scheme(myapp://) as link. Only app.myapp.com/data is showing as link. I have tried below code:

Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT,"Please check this link: "+Html.fromHtml("myapp://app.myapp.com/data"));
            intent.setType("text/plain");
startActivity(Intent.createChooser(intent, "Select Chooser to send friend"));

Is it possible to send link with custom scheme on WhatsApp in android platform?

Durgesh
  • 291
  • 2
  • 19
Jai
  • 33
  • 7

1 Answers1

-1

try this code:

 Whatsappbutton.setOnClickListener(new OnClickListener() {

            @SuppressLint("NewApi") @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                try {
                    Tracker t = ((Analytics) getActivity().getApplication())
                            .getTracker(TrackerName.APP_TRACKER);

                    t.send(new HitBuilders.EventBuilder()
                            .setCategory(getString(R.string.ic_Category))
                            .setAction(getString(R.string.ic_action))
                            .setLabel(getString(R.string.ic_labelwhatsapp)).build());
                } catch (Exception e) {
                    Toast.makeText(getActivity().getApplicationContext(),
                            "Error" + e.getMessage(), 1).show();
                }
                Toast.makeText(getActivity(), R.string.invite_friends_toast_after_share, Toast.LENGTH_LONG).show();

                final String shareBody = getResources().getString(R.string.invite_friends_market_url);
                try {
                    Intent shareToWhatsApp = new Intent(Intent.ACTION_SEND);
                    shareToWhatsApp.setType("text/plain");



       shareToWhatsApp.putExtra(android.content.Intent.EXTRA_TEXT, 

       shareBody);

                    shareToWhatsApp.setClassName("com.whatsapp",  

                   "com.whatsapp.ContactPicker");
                    startActivity(shareToWhatsApp);
                } catch (Exception e) {
                    Intent shareGeneric = new Intent(Intent.ACTION_SEND);
                    shareGeneric.setType("text/plain");
                    shareGeneric.putExtra(android.content.Intent.EXTRA_TEXT, 

                    shareBody);

                    startActivity(Intent.createChooser(shareGeneric,    
   getResources().getString(R.string.invite_friends_share_chooser)));
                }

            }
        });
Damini Mehra
  • 3,257
  • 3
  • 13
  • 24