Java tutorial
//package com.java2s; //License from project: Open Source License import android.net.Uri; import java.util.List; public class Main { private static final String[] MASK_HOSTS = { "m.facebook.com", "link2.tapatalk.com", "link.tapatalk.com", "google.com", "m.vk.com", "click.linksynergy.com", "youtube.com", "m.scope.am", "redirectingat.com", "jdoqocy.com", "viglink.com", "youtube.com" }; private static final String[] MASK_HOSTS_SEG = { "l.php", null, null, "url", "away.php", null, "attribution_link", "api", "rewrite.php", null, "api", "attribution_link" }; /** * Return the position of the host in MASK_HOSTS, or -1 if it isn't a known URL masker */ public static int getMaskedId(Uri uri) { String host = uri.getHost(); for (int i = 0; i < MASK_HOSTS.length; i++) { if (host.endsWith(MASK_HOSTS[i])) { if (MASK_HOSTS_SEG[i] == null) { return i; } else { List pathSegments = uri.getPathSegments(); if (pathSegments == null) return -1; if (pathSegments.size() > 0 && MASK_HOSTS_SEG[i].equals(pathSegments.get(0))) return i; } } } return -1; } }