0

I have share intent in my app to share app link with users via whatsapp,email etc.After sending link when user click on link it says even though I am passing correct play store url.

Below is my code:

Intent shareIntent = new Intent(Intent.ACTION_SEND);
            shareIntent.setType("text/plain");
            shareIntent.putExtra(Intent.EXTRA_SUBJECT,"Bookbudi app");
            shareIntent.putExtra(Intent.EXTRA_TEXT, "Hello there, I found this awesome app take a look."+" https://play.google.com/store/apps/details?id=com.app.myapp");

            startActivity(Intent.createChooser(shareIntent,"Share via"));

Someone please let me know what I am doing wrong. Any help would be appreciated.

THANKS

Digvijay
  • 2,887
  • 3
  • 36
  • 86
  • [please check this URL hop so your worked this ](https://stackoverflow.com/questions/11753000/how-to-open-the-google-play-store-directly-from-my-android-application) – Raju Tukadiya Aug 23 '19 at 12:44

3 Answers3

0

Here is a function you can use:

public void openAppOnStore(Context context, String appID) {
    try {
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(AppConstant.Google_Play_URL + appID));
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        if (null != intent.resolveActivity(context.getPackageManager())) {
            context.startActivity(intent);
        }
    }
    catch (ActivityNotFoundException e) {
        try {
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(AppConstant.Market_URL + appID));
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
            if (null != intent.resolveActivity(context.getPackageManager())) {
                context.startActivity(intent);
            }
        }
        catch (ActivityNotFoundException e1) {
            e1.printStackTrace();
        }
        catch (Exception e1) {
            e1.printStackTrace();
        }
    }
    catch (Exception e1) {
        e1.printStackTrace();
    }
Abdullah Riaz
  • 536
  • 5
  • 19
0

This will let you choose from email, whatsapp or whatever. Give Some space b/w your message and app link.

try { 
        Intent shareIntent = new Intent(Intent.ACTION_SEND);  
        shareIntent.setType("text/plain");
        shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Your application name");
        String shareMessage= "\nLet me recommend you this application\n\n";
        shareMessage = shareMessage + "https://play.google.com/store/apps/details?id=" + BuildConfig.APPLICATION_ID +"\n\n";
        shareIntent.putExtra(Intent.EXTRA_TEXT, shareMessage);  
        startActivity(Intent.createChooser(shareIntent, "choose one"));
    } catch(Exception e) { 
         e.printStackTrace();
    }   
Sandeep Malik
  • 1,972
  • 1
  • 8
  • 17
0

Please check your play store URL first that you are providing. I think it's not working although you have done everything right.

Rohan
  • 96
  • 8