2

I need to send app invitation message from my app to friends via whatsapp,facebook,hike,... with the message and playstore link.I have seen this kind of invitations in other apps like hike,whatscall,... like the attached image below. hike and whatscall

I want to send exactly the same kind of message with the playstore link and app logo for my app also and it should be shared using all the available sharing option in users mobile.In my application i have included a inform friends menu and on clicking on that this function should work.I have seen firebase app invite examples but it needs google-services.json and i think it will only send text message from users email,I am not sure about that.

KJEjava48
  • 1,967
  • 7
  • 40
  • 69

2 Answers2

3

You need to create an intent as follows which will allow you to share your app using any other app :

    try { 
        Intent i = new Intent(Intent.ACTION_SEND);  
        i.setType("text/plain");
        i.putExtra(Intent.EXTRA_SUBJECT, "My app name");
        String strShareMessage = "\nLet me recommend you this application\n\n";
        strShareMessage = strShareMessage + "https://play.google.com/store/apps/details?id=" + getPackageName();
        Uri screenshotUri = Uri.parse("android.resource://packagename/drawable/image_name");
        i.setType("image/png");
        i.putExtra(Intent.EXTRA_STREAM, screenshotUri);
        i.putExtra(Intent.EXTRA_TEXT, strShareMessage);  
        startActivity(Intent.createChooser(i, "Share via"));
    } catch(Exception e) { 
        //e.toString();
    }
Suraj Makhija
  • 1,376
  • 8
  • 16
1

You can try this,

Intent intent = new Intent();
intent.setComponent(new ComponentName(packageName, resolveInfo.activityInfo.name));
intent.setAction(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT,"Your String");
intent.putExtra(Intent.EXTRA_SUBJECT, "Share " + "From");
intent.setPackage(packageName);
ActivityName.startActivity(intent);
Gohel Dhaval
  • 820
  • 1
  • 8
  • 12
  • how can i include my app logo image along with this message ??The message should contain a header,logo image,body and the playstore app link – KJEjava48 Mar 29 '17 at 06:58
  • change intent.setType("text/palin") to intent.setType("image/*") and intent.putExtra(Intent.EXTRA_STREAM, url of image); – Gohel Dhaval Mar 29 '17 at 07:01