Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1014397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:14:54+00:00 2026-05-16T10:14:54+00:00

I know this has been asked a lot of times in StackOverflow already, but

  • 0

I know this has been asked a lot of times in StackOverflow already, but I haven’t quite found a solution yet. My app sends an email with a link in it that when clicked should launch the app.

According to @hackbod, the best way to do it is to make use of the Intent URI (see this). Here’s my code that sets the intent and puts it in the email body:

Intent customIntent = new Intent(CUSTOM_ACTION);
customIntent.setPackage(MY_PACKAGE);
customIntent.addCategory(MY_CAT_BROWSABLE);
customIntent.addCategory(MY_CAT_DEFAULT);

String customUri = customIntent.toUri(Intent.URI_INTENT_SCHEME);

String emailBody = getString(R.string.intent_link, customUri);

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/html");
intent.putExtra(Intent.EXTRA_SUBJECT, "Recommending vid");
intent.putExtra(Intent.EXTRA_TEXT   , Html.fromHtml(emailBody));
try {
    startActivity(Intent.createChooser(intent, "Choose email client:"));
} catch (android.content.ActivityNotFoundException ex) {
    Toast.makeText(this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}

This is what I get from LogCat:

08-25 17:01:23.333: VERBOSE/Test URI(16987): intent:#Intent;action=com.test.project.action.VIEW_VID_FROM_LINK;category=android.intent.category.DEFAULT;category=android.intent.category.BROWSABLE;package=com.test.project;end
08-25 17:01:23.338: VERBOSE/Test email text(16987): Hi,<br><br>Testing intents from an email.<br><br> A standard website: <a href=http://www.google.com>Go to Google</a>.<br><br> This link should launch the app: <a href=intent:#Intent;action=com.test.project.action.VIEW_VID_FROM_LINK;category=android.intent.category.DEFAULT;category=android.intent.category.BROWSABLE;package=com.test.project;end>Click link to launch</a>.

When I view the email from my phone using the GMail app, I can click on the Google link and it launches the browser, no problem with that.

But the link for the intent is not even clickable (While from the draft it looks like it should be clickable). Has anybody tried this and made it work?

From draft: link looks clickableSent email: link not clickable

EDIT #1: I have also tried setting the action to Intent.ACTION_VIEW but the link is still not clickable.

EDIT #2: Apparently, the link really is clickable. I tried using another email client, and the links are clickable! Seems like there is a bug in GMail. Oh well. But apparently, this is harder than I thought. I tried using:

Uri.Builder builder = new Uri.Builder();
builder.scheme("my.own.scheme");
builder.authority("my.authority");
Uri newUri = builder.build();
Intent customIntent = new Intent(CUSTOM_ACTION, newUri);

As suggested by @CommonsWare, I tried checking if there are receivers of this customIntent. Apparently there is one, which is what I was expecting. So next step is to make this intent into a URI that I can use in the email. I used:

String customUri = customIntent.toUri(Intent.URI_INTENT_SCHEME);

which, based on my understanding of the documentation, should give me something like the usual http links, only with the scheme set to intent. I can then use this customUri as the value for the links in the email. BUT, it looks like this is not the case. Does anybody have an example of what .toUri must return?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T10:14:54+00:00Added an answer on May 16, 2026 at 10:14 am

    You could try quotes around your URLs in your <a> elements, since that is how HTML is supposed to be written.

    You might also try confirming, via parseUri(), PackageManager, and queryIntentActivities(), if your generated URL resolves to something — if it does not, then there is a problem with the URL.

    Here is a sample project showing the use of URI_INTENT_SCHEME, in case it gives you any ideas.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Yes, I know this question has been asked a lot of times, but I
I know this has been asked many times but i'm yet to find a
I know this has been asked a lot of times, but I have honestly
I know this type of question has been asked a lot, but I haven't
I know this question has been asked a lot of times, but so far,
I know this question has already been asked a lot, but I don't get
I know this question has been asked several times, but I can't quite seem
I know this has been asked at least a thousand times but I can't
I know this has been asked different ways several times, but I'm just not
I know this has been asked thousands of times but I just can't find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.