Creating hyperlinks to Android seems like a simple task - until you come across the nuances. Depending on the context (a message in the messenger, application code or web page), the methods are radically different. For example, in WhatsApp a link will be inserted automatically, and during development APK markup XML and processing of clicks in Java/Kotlinwill be required. This article covers all scenarios - from basic to professional, taking into account the features of different versions. data-i="41">does not recognize links without Android (from 4.4 KitKat to 14).

We will look at not only how to insert a link into the text, but also how to make it opening. in the desired browser, how to bypass restrictions of some applications (for example, Telegram does not recognize links without http://), and we will even pay special attention to how to create a custom hyperlink in your application with animation hidden Android settings that allow you to change the behavior of links globally - for example, force all links to open in Chrome, and not in the application web viewer.

The most common case is inserting a link in a message: It all depends on the application:

  • ๐Ÿ“ฑ WhatsApp/Viber: Links are recognized automatically. Just paste the URL (for example, https://example.com), and it will become clickable. Shortened links are supported (bit.ly, t.co).
  • ๐Ÿ’ฌ Telegram: requires an explicit protocol (http:// or https://). Without it, the text will not become a link, even if it looks like it. URL.
  • ๐Ÿ“ง Gmail/Mail: automatically converts into a hyperlink any text starting with www., http:// or mailto:.
  • ๐Ÿ“ Google Docs: select the text โ†’ click "Insert link" (chain icon) โ†’ enter URL Anchor links are supported. (#section).

โš ๏ธ Attention: B Facebook Messenger and Instagram Direct links only work if they start with http:// or https://. Simply example.com will not work. This is a platform limitation and cannot be circumvented.

๐Ÿ“Š Which messenger do you most often share links with?
WhatsApp
Telegram
Viber
Facebook Messenger
Other

To format links in Telegram you can use Markdown or HTML:

[Link text](https://example.com)  

Link text

If you edit an HTML page on Android (for example, via QuickEdit or Acode), hyperlinks are created with a standard tag <a>Features:

  • ๐ŸŒ Attribute target: by default, links open in the same. window. To open in a new tab, add target="_blank".
  • ๐Ÿ“ฑ Adaptability: on mobile devices it is better to avoid target="_blank" - this may cause problems with returning to the page.
  • ๐Ÿ”— Phone links: use for calls Call.
  • ๐Ÿ“ง Mail links: Write.

Example of code taking into account mobile features:

<a href="https://example.com"

target="_self"

rel="noopener noreferrer">

Go to the site

</a>

๐Ÿ’ก

To check how the link will look on Android, open the HTML file through the browser Chrome in "For Developers" mode (F12 โ†’ switch to mobile device).

Attribute Value Explanation
href https://example.com Main link URL
target _self, _blank Where to open: in this window or a new one
rel noopener noreferrer Security for target="_blank"
download filename.ext Forced file download

When creating your own application, hyperlinks are implemented via TextView with the attribute android:autoLink or programmatically via SpannableString. Let's consider both options.

Method 1: Automatic links in XML

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Visit https://example.com"

android:autoLink="web|phone|email|all" />

Parameters autoLink:

  • web - recognizes HTTP/HTTPS links
  • phone - telephone numbers
  • email โ€” email addresses
  • all โ€”all of the above

Method 2: Custom links via SpannableString

val text = "Click here to go"

val spannableString = SpannableString(text)

val clickableSpan = object : ClickableSpan() {

override fun onClick(widget: View) {

val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://example.com"))

startActivity(intent)

}

}

spannableString.setSpan(clickableSpan, 0, text.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)

textView.text = spannableString

textView.movementMethod = LinkMovementMethod.getInstance()

How to change the color of a custom link?

Add to the code before setSpan the line: clickableSpan.setColor(ContextCompat.getColor(context, R.color.your_color))

Or use ForegroundColorSpan for part of the text.

โš ๏ธ Attention: Starting from Android 10 (API 29), opening links in the browser requires an explicit instruction package via Intent:

intent.setPackage("com.android.chrome") // Force open in Chrome

Android allows you to change the application that opens links by default This is useful if you. do you prefer Chrome instead of the built-in browser or a specialized application for mailto:.

Instructions:

  1. Open Settings โ†’ Applications.
  2. Click on the three dots in the upper right corner โ†’ Default applications.
  3. Select Browser or Open links (names may vary).
  4. Specify the preferred application (for example, Chrome, Firefox).

The application is installed as the default handler|Links open without additional dialogs|Test link mailto: opens an email client|Test link tel: offers a call -->

For advanced users: you can force reset the settings of handlers through ADB:

adb shell pm clear-defaults com.android.chrome

Applications for working with text (Google Keep, Evernote, Microsoft Word) support links, but with nuances:

Application Link support Features
Google Keep Yes Automatic URL recognition, but without the ability to change the text links
Evernote Yes Supports formatting (text selection โ†’ "Link")
Microsoft Word Yes Editing via "Insert โ†’ Hyperlink", works offline
Notion Yes Links in Markdown format ([text](url))

In Google Docs you can create internal link to the title of the same document:

  1. Select the text that will become a link (for example, "Return to top").
  2. Click on the link icon in the toolbar.
  3. In the drop-down menu, select the document title (for example, "Title 1").

Sometimes links do not work or lead to the wrong place. Common reasons and solutions:

  • ๐Ÿ”ง The link is not clickable:
    • Check if the URL begins with http:// or https://.
    • In Telegram add a space after the link.
    • In HTML, check the closing tag </a>.
  • ๐Ÿ”„ The link is opening in the wrong application:
    • Reset the handler settings (see section 4).
    • Delete the browser cache (Settings โ†’ Applications โ†’ Chrome โ†’ Memory โ†’ Clear cache).
  • ๐Ÿšซ Blocking links:
    • Some applications (for example, VK) block external links. Use shorteners (bit.ly).
    • In Android 12+ phishing protection may be triggered - check system notifications.
๐Ÿ’ก

If the link leads to play.google.com, but opens in the browser instead Google Play, clear the application data Google Play Services in the settings.

โš ๏ธ Attention: On devices with Android Go (for example, Nokia 1, Samsung Galaxy J2 Core) some link processing functions may be limited due to system optimization. In this case, it is recommended to use Chrome Go as the default browser.

Deep links allow you to open not just web pages, but specific sections of applications. For example, a link like exampleapp://profile/123 can open the profile of a user with ID 123 in a mobile application.

How it works:

  1. The developer registers the URL scheme in AndroidManifest.xml:
    <intent-filter>
    

    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.DEFAULT" />

    <category android:name="android.intent.category.BROWSABLE" />

    <data android:scheme="exampleapp" android:host="profile" />

    </intent-filter>

  2. The user follows the link exampleapp://profile/123.
  3. Android redirects the request to the application if it is installed.

Examples of deep links of popular applications:

  • whatsapp://send?phone=79991234567 โ€” open a chat on WhatsApp.
  • tg://resolve?domain=username โ€”profile on Telegram.
  • vk://wall-12345_678 โ€”post on VKontakte.
How to find the Deep Link scheme for an application?

1. Decompile the APK via JADX or Apktool.

2. Look AndroidManifest.xml - look for tags <data android:scheme="...">.

3. For popular applications, diagrams can be found on sites like Awesome Deep Link (will open in a new tab).

Can I link to a phone number in SMS?

Yes, but only if the recipient uses Android or iPhone with support for automatic recognition. Format: Call me: +79991234567. Tapping the number will open the Phone app. On some devices (for example, Xiaomi s MIUI), you may need to add a space after the number.

Why in my application links open in the built-in browser, and not in Chrome?

This behavior is set in AndroidManifest.xml or via Intent. To force open in Chrome, modify the intent:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://example.com"));

intent.setPackage("com.android.chrome");

startActivity(intent);

If Chrome is not installed, add a check:

PackageManager pm = getPackageManager();

if (intent.resolveActivity(pm) != null) {

startActivity(intent);

} else {

// Falls on a standard browser

intent.setPackage(null);

startActivity(intent);

}

How to insert a link in Instagram stories from Android?

You can only add a link to Instagram add link to Stoires if you have 10,000+ subscribers or a verified account. Alternatives:

  • Use "Swipe up" (available for business accounts with 10k subscribers).
  • Add a link in bio (instagram.com/yourprofile) and mention it in stories.
  • Use services like Linktree to create a page with several links.
Is it possible to disable link previews in Telegram?

Yes, this is a chat setting. Open the dialogue โ†’ click on the name of the interlocutor/group โ†’ Chat type โ†’ disconnect Link preview. You can also disable preview for all chats in Settings โ†’ Data and memory โ†’ Link preview.

How to make links in my application open in WebView, and not in the browser?

Use WebViewClient to intercept clicks:

webView.setWebViewClient(new WebViewClient() {

@Override

public boolean shouldOverrideUrlLoading(WebView view, String url) {

view.loadUrl(url); // Open inside the WebView

return true;

}

});

To process specific links (for example, only https://yourdomain.com):

@Override

public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {

if (request.getUrl().toString().contains("yourdomain.com")) {

view.loadUrl(request.getUrl().toString());

return true;

}

// Open the remaining links in the browser

Intent intent = new Intent(Intent.ACTION_VIEW, request.getUrl());

startActivity(intent);

return true;

}