Share app link – Android Programming


Share app on a button click – Android

Almost all available app on Google Play Store has a share option. Clicking on the share option a user can share the app’s link with anyone. When someone clicks the link, it takes them to the Play Store page and from there they can easily download the app.


Here in this post, I am going to make a simple project which will have only one activity. And there will be a layout file of our MainActivity with just a share button. Now when someone clicks the button, the app chooser dialog will open. From the app chooser dialog, they can choose the app using which they can share the app link with others.

Now let’s create a new Android project. Name your project.  I am naming it ShareMyApp.

Open your activity layout file and paste the code below –

Now let’s code the class.

Here we just have to send our app’s link to other apps. So we will be using Intent.ACTION_SEND and the MIME/TYPE as TEXT/PLAIN.

To set the MIME/TYPE we can use setType on our intent object.

If you omit the line “intent.setType(“text/plain”);”, the app chooser dialog will open but with no apps in it. You will see a message “No apps can perform this action”.

Here we want to send plain text. So we also have to use Intent.EXTRA_TEXT.

Remember whenever you are using Intent.EXTRA_TEXT, the MIME TYPE should be text/plain.

In the above code, the extraText is the link to your app. You can also add some text to it.

At last, create the chooser dialog –

Below is the complete code.Copy it and update your activity code.

Now run your project and click the share button. The app chooser will open and from there you can choose an app and share your app’s link.


You May Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *