Example usage for android.net Uri getHost

List of usage examples for android.net Uri getHost

Introduction

In this page you can find the example usage for android.net Uri getHost.

Prototype

@Nullable
public abstract String getHost();

Source Link

Document

Gets the encoded host from the authority for this URI.

Usage

From source file:com.takondi.tartt.ARActivity.java

@Override
public boolean urlWasInvoked(String url) {
    Log.d(TAG, "urlWasInvoked " + url);
    if (url != null) {
        Uri uri = Uri.parse(url);
        if (URL_ARCHITECTSDK_SCHEME.equals(uri.getScheme())) {
            JSONObject paramJson = new JSONObject();
            if (!uri.getQueryParameterNames().isEmpty()) {
                for (String param : uri.getQueryParameterNames()) {
                    try {
                        paramJson.put(param, uri.getQueryParameter(param));
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }/*w ww.ja  v  a 2 s  .  c om*/
                }
            }
            handleEvent(uri.getHost(), paramJson);
        }
    }
    return false;
}

From source file:org.openhab.habdroid.ui.OpenHABWidgetListActivity.java

/**
 * This method processes new intents generated by NFC subsystem
 * @param nfcData - a data which NFC subsystem got from the NFC tag
 * @param pushCurrentToStack/*from  ww  w.j a  v a2  s . c o  m*/
 */
public void onNfcTag(String nfcData, boolean pushCurrentToStack) {
    Uri openHABURI = Uri.parse(nfcData);
    Log.d(TAG, openHABURI.getScheme());
    Log.d(TAG, openHABURI.getHost());
    Log.d(TAG, openHABURI.getPath());
    if (openHABURI.getHost().equals("sitemaps")) {
        Log.d(TAG, "Tag indicates a sitemap link");
        String newPageUrl = this.openHABBaseUrl + "rest/sitemaps" + openHABURI.getPath();
        String widgetId = openHABURI.getQueryParameter("widget");
        String command = openHABURI.getQueryParameter("command");
        Log.d(TAG, "widgetId = " + widgetId);
        Log.d(TAG, "command = " + command);
        if (widgetId != null && command != null) {
            this.nfcWidgetId = widgetId;
            this.nfcCommand = command;
            // If we have widget+command and not pushing current page to stack
            // this means we started through NFC read when HABDroid was not running
            // so we need to put a flag to automatically close activity after we
            // finish nfc action
            if (!pushCurrentToStack)
                this.nfcAutoClose = true;
        }
        Log.d(TAG, "Should go to " + newPageUrl);
        if (pushCurrentToStack)
            navigateToPage(newPageUrl, "");
        else
            openSitemap(newPageUrl);
    }
}

From source file:org.mozilla.gecko.home.BrowserSearch.java

private String findAutocompletion(String searchTerm, Cursor c, boolean searchPath) {
    if (!c.moveToFirst()) {
        return null;
    }//from  w w w .j a va 2s  .co  m

    final int searchLength = searchTerm.length();
    final int urlIndex = c.getColumnIndexOrThrow(History.URL);
    int searchCount = 0;

    do {
        final String url = c.getString(urlIndex);

        if (searchCount == 0) {
            // Prefetch the first item in the list since it's weighted the highest
            GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Session:Prefetch", url));
        }

        // Does the completion match against the whole URL? This will match
        // about: pages, as well as user input including "http://...".
        if (url.startsWith(searchTerm)) {
            return uriSubstringUpToMatchedPath(url, 0,
                    (searchLength > HTTPS_PREFIX_LENGTH) ? searchLength : HTTPS_PREFIX_LENGTH);
        }

        final Uri uri = Uri.parse(url);
        final String host = uri.getHost();

        // Host may be null for about pages.
        if (host == null) {
            continue;
        }

        if (host.startsWith(searchTerm)) {
            return host + "/";
        }

        final String strippedHost = StringUtils.stripCommonSubdomains(host);
        if (strippedHost.startsWith(searchTerm)) {
            return strippedHost + "/";
        }

        ++searchCount;

        if (!searchPath) {
            continue;
        }

        // Otherwise, if we're matching paths, let's compare against the string itself.
        final int hostOffset = url.indexOf(strippedHost);
        if (hostOffset == -1) {
            // This was a URL string that parsed to a different host (normalized?).
            // Give up.
            continue;
        }

        // We already matched the non-stripped host, so now we're
        // substring-searching in the part of the URL without the common
        // subdomains.
        if (url.startsWith(searchTerm, hostOffset)) {
            // Great! Return including the rest of the path segment.
            return uriSubstringUpToMatchedPath(url, hostOffset, hostOffset + searchLength);
        }
    } while (searchCount < MAX_AUTOCOMPLETE_SEARCH && c.moveToNext());

    return null;
}

From source file:onion.chat.MainActivity.java

void handleIntent() {

    Intent intent = getIntent();//from www .  j av  a2s .  c om
    if (intent == null) {
        return;
    }

    Uri uri = intent.getData();
    if (uri == null) {
        return;
    }

    if (!uri.getHost().equals("chat.onion")) {
        return;
    }

    List<String> pp = uri.getPathSegments();
    String address = pp.size() > 0 ? pp.get(0) : null;
    String name = pp.size() > 1 ? pp.get(1) : "";
    if (address == null) {
        return;
    }

    addContact(address, name);
    inform();

}

From source file:de.enlightened.peris.IntroScreen.java

@SuppressLint("NewApi")
public final void onCreate(final Bundle savedInstanceState) {
    this.dbHelper = new PerisDBHelper(this);
    final Bundle bundle = getIntent().getExtras();
    if (bundle != null) {
        if (bundle.containsKey("server_id")) {
            if (bundle.getString("server_id") != null) {

                this.incomingShortcut = true;
                this.shortcutServerId = bundle.getString("server_id");
            }//from  w  w  w  .jav  a  2 s  .  com
        }
    }

    final PerisApp app = (PerisApp) getApplication();
    app.initSession();

    startService(new Intent(this, MailService.class));
    this.initDatabase();

    final SharedPreferences appPreferences = getSharedPreferences("prefs", 0);

    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    final SharedPreferences.Editor editor = appPreferences.edit();
    editor.putString("server_address", getString(R.string.server_location));
    editor.commit();

    final String backgroundColor = app.getSession().getServer().serverColor;

    ThemeSetter.setTheme(this, backgroundColor);

    super.onCreate(savedInstanceState);

    ThemeSetter.setActionBar(this, backgroundColor);

    //Track app analytics
    this.ah = ((PerisApp) getApplication()).getAnalyticsHelper();
    this.ah.trackScreen(getString(R.string.app_name) + " v" + getString(R.string.app_version) + " for Android",
            true);

    setContentView(R.layout.intro_screen);

    this.serverInputter = (EditText) findViewById(R.id.intro_screen_add_server_box);

    final Button serverAdder = (Button) findViewById(R.id.intro_screen_submit_new_server);

    serverAdder.setOnClickListener(new View.OnClickListener() {

        @SuppressWarnings("checkstyle:requirethis")
        public void onClick(final View v) {

            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
                new ServerValidationTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,
                        serverInputter.getText().toString().trim());
            } else {
                new ServerValidationTask().execute(serverInputter.getText().toString().trim());
            }

        }
    });

    this.lvServers = (ListView) findViewById(R.id.intro_screen_server_list);
    this.gvServers = (GridView) findViewById(R.id.intro_screen_server_grid);

    if (this.lvServers == null) {
        registerForContextMenu(this.gvServers);
        this.gvServers.setOnItemClickListener(new OnItemClickListener() {
            @SuppressWarnings("checkstyle:requirethis")
            public void onItemClick(final AdapterView<?> parent, final View view, final int position,
                    final long id) {
                final Server server = serverList.get(position);
                connectToServer(server);
            }
        });
    } else {
        this.lvServers.setDivider(null);
        registerForContextMenu(this.lvServers);

        this.lvServers.setOnItemClickListener(new OnItemClickListener() {
            @SuppressWarnings("checkstyle:requirethis")
            public void onItemClick(final AdapterView<?> parent, final View view, final int position,
                    final long id) {
                final Server server = serverList.get(position);
                connectToServer(server);
            }
        });
    }

    final TextView tvTapaShoutout = (TextView) findViewById(R.id.intro_screen_app_title);
    tvTapaShoutout.setOnClickListener(new View.OnClickListener() {

        public void onClick(final View v) {
            final Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("https://github.com/McNetic/peris"));
            startActivity(browserIntent);
        }
    });

    //Check for incoming link from tapatalk :-)
    String host = "";

    final Uri data = getIntent().getData();

    if (data != null) {
        host = data.getHost();
        this.stealingType = data.getQueryParameter("location");

        if (this.stealingType == null) {
            this.stealingType = "0";
        } else {
            if (this.stealingType.contentEquals("forum")) {
                final String forumId = data.getQueryParameter("fid");

                if (forumId == null) {
                    this.stealingLocation = "0";
                } else {
                    this.stealingLocation = forumId;
                }
            }

            if (this.stealingType.contentEquals("topic")) {
                final String topicId = data.getQueryParameter("tid");

                if (topicId == null) {
                    this.stealingLocation = "0";
                } else {
                    this.stealingLocation = topicId;
                }
            }
        }

    }

    if (host.length() > 0) {
        this.linkToSteal = host;
        this.stealingLink = true;
        return;
    }

}

From source file:com.lloydtorres.stately.helpers.SparkleHelper.java

/**
 * Finds all raw URL links and URL tags and linkifies them properly in a nice format.
 * @param c App context.//from  w w  w . j  ava 2  s .co  m
 * @param content Target string.
 * @return Parsed results.
 */
public static String regexGenericUrlFormat(Context c, String content) {
    String holder = content;

    Map<String, String> replaceBasic = new HashMap<String, String>();
    Matcher m0 = BBCODE_URL.matcher(holder);
    while (m0.find()) {
        String template = "<a href=\"%s\">%s</a>";
        Uri link = Uri.parse(m0.group(1)).normalizeScheme();
        if (link.getScheme() == null) {
            template = "<a href=\"http://%s\">%s</a>";
        }
        String replaceText = String.format(Locale.US, template, link.toString(), m0.group(2));
        replaceBasic.put(m0.group(), replaceText);
    }
    Set<Map.Entry<String, String>> setBasic = replaceBasic.entrySet();
    for (Map.Entry<String, String> e : setBasic) {
        holder = holder.replace(e.getKey(), e.getValue());
    }

    Map<String, String> replaceRaw = new HashMap<String, String>();

    Matcher m1 = RAW_HTTP_LINK.matcher(holder);
    while (m1.find()) {
        Uri link = Uri.parse(m1.group(1)).normalizeScheme();
        String replaceText = String.format(Locale.US, c.getString(R.string.clicky_link_http), link.toString(),
                link.getHost());
        replaceRaw.put(m1.group(), replaceText);
    }

    Matcher m2 = RAW_WWW_LINK.matcher(holder);
    while (m2.find()) {
        Uri link = Uri.parse("http://" + m2.group(1)).normalizeScheme();
        String replaceText = String.format(Locale.US, c.getString(R.string.clicky_link_http), link.toString(),
                link.getHost());
        replaceRaw.put(m2.group(), replaceText);
    }

    Set<Map.Entry<String, String>> set = replaceRaw.entrySet();
    for (Map.Entry<String, String> e : set) {
        holder = holder.replaceAll(
                "(?<=^|\\s|<br \\/>|<br>|<b>|<i>|<u>)\\Q" + e.getKey() + "\\E(?=$|[\\s\\[\\<])", e.getValue());
    }

    return holder;
}

From source file:com.odoo.core.rpc.wrapper.OdooWrapper.java

private void getDatabaseList(final IDatabaseListListener callback, OdooSyncResponse backResponse) {

    try {/*ww  w.j a v  a 2s  .  c o m*/
        if (odooSession.getDb() != null && !odooSession.getDb().equals("false")) {
            // Ignoring if server is odoo.com
            if (callback != null) {
                callback.onDatabasesLoad(Collections.singletonList(odooSession.getDb()));
            } else {
                OdooResponse response = new OdooResponse();
                OdooResult result = new OdooResult();
                result.put("result", Collections.singletonList(odooSession.getDb()));
                response.result = result;
                backResponse.setResponse(response);
            }
        } else {
            Uri uri = Uri.parse(serverURL);
            if (!isRunbotURL(serverURL) && uri.getHost().endsWith(".odoo.com")
                    && mVersion.getVersionNumber() >= 10) {
                String[] parts = uri.getHost().split("\\.");
                if (callback != null) {
                    callback.onDatabasesLoad(Collections.singletonList(parts[0]));
                } else {
                    OdooResponse response = new OdooResponse();
                    OdooResult result = new OdooResult();
                    result.put("result", Collections.singletonList(parts[0]));
                    response.result = result;
                    backResponse.setResponse(response);
                }
            } else {
                String url = serverURL;
                JSONObject params = new JSONObject();
                // Fix for listing databases. Removed get_list from odoo 9.0+
                if (mVersion.getVersionNumber() == 9) {
                    url += "/jsonrpc";
                    params.put("method", "list");
                    params.put("service", "db");
                    params.put("args", new JSONArray());
                } else if (mVersion.getVersionNumber() >= 10) {
                    url += "/web/database/list";
                    params.put("context", new JSONObject());
                } else {
                    url += "/web/database/get_list";
                    params.put("context", new JSONObject());
                }
                newJSONPOSTRequest(url, params, new IOdooResponse() {
                    @Override
                    public void onResponse(OdooResult response) {
                        List<String> dbs = response.getArray("result");
                        List<String> dbNames = new ArrayList<>();
                        dbNames.addAll(dbs);
                        // Fix for runtbot databases. Filtering from host prefix
                        if (isRunbotURL(serverURL)) {
                            String dbPrefix = getDBPrefix(serverURL);
                            dbNames.clear();
                            for (String db : dbs) {
                                if (db.contains(dbPrefix)) {
                                    dbNames.add(db);
                                }
                            }
                        }
                        callback.onDatabasesLoad(dbNames);
                    }

                    @Override
                    public void onError(OdooError error) {
                        if (mIOdooConnectionListener != null) {
                            mIOdooConnectionListener.onError(error);
                        }
                    }
                }, backResponse);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.google.android.apps.muzei.provider.MuzeiProvider.java

private File getCacheFileForArtworkUri(Uri artworkUri) {
    Context context = getContext();
    if (context == null || artworkUri == null) {
        return null;
    }/* w w w  . ja  v  a  2s .c  o  m*/
    File directory = new File(context.getFilesDir(), "artwork");
    if (!directory.exists() && !directory.mkdirs()) {
        return null;
    }
    String[] projection = { BaseColumns._ID, MuzeiContract.Artwork.COLUMN_NAME_IMAGE_URI,
            MuzeiContract.Artwork.COLUMN_NAME_TOKEN };
    Cursor data = queryArtwork(artworkUri, projection, null, null, null);
    if (data == null) {
        return null;
    }
    if (!data.moveToFirst()) {
        Log.e(TAG, "Invalid artwork URI " + artworkUri);
        return null;
    }
    // While normally we'd use data.getLong(), we later need this as a String so the automatic conversion helps here
    String id = data.getString(0);
    String imageUri = data.getString(1);
    String token = data.getString(2);
    data.close();
    if (TextUtils.isEmpty(imageUri) && TextUtils.isEmpty(token)) {
        return new File(directory, id);
    }
    // Otherwise, create a unique filename based on the imageUri and token
    StringBuilder filename = new StringBuilder();
    if (!TextUtils.isEmpty(imageUri)) {
        Uri uri = Uri.parse(imageUri);
        filename.append(uri.getScheme()).append("_").append(uri.getHost()).append("_");
        String encodedPath = uri.getEncodedPath();
        if (!TextUtils.isEmpty(encodedPath)) {
            int length = encodedPath.length();
            if (length > 60) {
                encodedPath = encodedPath.substring(length - 60);
            }
            encodedPath = encodedPath.replace('/', '_');
            filename.append(encodedPath).append("_");
        }
    }
    // Use the imageUri if available, otherwise use the token
    String unique = !TextUtils.isEmpty(imageUri) ? imageUri : token;
    try {
        MessageDigest md = MessageDigest.getInstance("MD5");
        md.update(unique.getBytes("UTF-8"));
        byte[] digest = md.digest();
        for (byte b : digest) {
            if ((0xff & b) < 0x10) {
                filename.append("0").append(Integer.toHexString((0xFF & b)));
            } else {
                filename.append(Integer.toHexString(0xFF & b));
            }
        }
    } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
        filename.append(unique.hashCode());
    }
    return new File(directory, filename.toString());
}

From source file:com.morphoss.acal.service.connector.AcalRequestor.java

/**
 * Interpret the URI in the string to set protocol, host, port & path for the next request.
 * If the URI only matches a path part then protocol/host/port will be unchanged. This call
 * will only allow for path parts that are anchored to the web root.  This is used internally
 * for following Location: redirects./* w ww .ja  v  a2  s  .  com*/
 *
 * This is also used to interpret the 'path' parameter to the request calls generally.
 *
 * @param uriString
 */
public void interpretUriString(String uriString) {

    if (uriString == null)
        return;

    // Match a URL, including an ipv6 address like http://[DEAD:BEEF:CAFE:F00D::]:8008/
    final Pattern uriMatcher = Pattern.compile("^(?:(https?)://)?" + // Protocol
            "(" + // host spec
            "(?:(?:[a-z0-9-]+[.]){1,7}(?:[a-z0-9-]+))" + // Hostname or IPv4 address
            "|(?:\\[(?:[0-9a-f]{0,4}:)+(?:[0-9a-f]{0,4})?\\])" + // IPv6 address
            ")" + "(?:[:]([0-9]{2,5}))?" + // Port number
            "(/.*)?$" // Path bit.
            , Pattern.CASE_INSENSITIVE | Pattern.DOTALL);

    final Pattern pathMatcher = Pattern.compile("^(/.*)$");

    if (Constants.LOG_VERBOSE)
        Log.println(Constants.LOGV, TAG, "Interpreting '" + uriString + "'");
    Matcher m = uriMatcher.matcher(uriString);
    if (m.matches()) {
        if (m.group(1) != null && !m.group(1).equals("")) {
            if (Constants.LOG_VERBOSE)
                Log.println(Constants.LOGV, TAG, "Found protocol '" + m.group(1) + "'");
            protocol = m.group(1);
            if (m.group(3) == null || m.group(3).equals("")) {
                port = (protocol.equals(PROTOCOL_HTTP) ? 80 : 443);
            }
        }
        if (m.group(2) != null) {
            if (Constants.LOG_VERBOSE)
                Log.println(Constants.LOGV, TAG, "Found hostname '" + m.group(2) + "'");
            setHostName(m.group(2));
        }
        if (m.group(3) != null && !m.group(3).equals("")) {
            if (Constants.LOG_VERBOSE)
                Log.println(Constants.LOGV, TAG, "Found port '" + m.group(3) + "'");
            port = Integer.parseInt(m.group(3));
            if (m.group(1) != null && (port == 0 || port == 80 || port == 443)) {
                port = (protocol.equals(PROTOCOL_HTTP) ? 80 : 443);
            }
        }
        if (m.group(4) != null && !m.group(4).equals("")) {
            if (Constants.LOG_VERBOSE)
                Log.println(Constants.LOGV, TAG, "Found path '" + m.group(4) + "'");
            setPath(m.group(4));
        }
        if (!initialised)
            initialise();
    } else {
        m = pathMatcher.matcher(uriString);
        if (m.find()) {
            if (Constants.LOG_VERBOSE)
                Log.println(Constants.LOGV, TAG, "Found relative path '" + m.group(1) + "'");
            setPath(m.group(1));
        } else {
            if (Constants.LOG_DEBUG)
                Log.println(Constants.LOGD, TAG, "Using Uri class to process redirect...");
            Uri newLocation = Uri.parse(uriString);
            if (newLocation.getHost() != null)
                setHostName(newLocation.getHost());
            setPortProtocol(newLocation.getPort(), newLocation.getScheme());
            setPath(newLocation.getPath());
            if (Constants.LOG_VERBOSE)
                Log.println(Constants.LOGV, TAG, "Found new location at '" + fullUrl() + "'");

        }
    }
}

From source file:org.runbuddy.tomahawk.activities.TomahawkMainActivity.java

private void handleIntent(Intent intent) {
    if (MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH.equals(intent.getAction())) {
        intent.setAction(null);/*w w  w  .  j  a  va  2  s  .  c  o m*/
        String playbackManagerId = getSupportMediaController().getExtras()
                .getString(PlaybackService.EXTRAS_KEY_PLAYBACKMANAGER);
        PlaybackManager playbackManager = PlaybackManager.getByKey(playbackManagerId);
        MediaPlayIntentHandler intentHandler = new MediaPlayIntentHandler(
                getSupportMediaController().getTransportControls(), playbackManager);
        intentHandler.mediaPlayFromSearch(intent.getExtras());
    }
    if ("com.google.android.gms.actions.SEARCH_ACTION".equals(intent.getAction())) {
        intent.setAction(null);
        String query = intent.getStringExtra(SearchManager.QUERY);
        if (query != null && !query.isEmpty()) {
            DatabaseHelper.get().addEntryToSearchHistory(query);
            Bundle bundle = new Bundle();
            bundle.putString(TomahawkFragment.QUERY_STRING, query);
            bundle.putInt(TomahawkFragment.CONTENT_HEADER_MODE, ContentHeaderFragment.MODE_HEADER_STATIC);
            FragmentUtils.replace(TomahawkMainActivity.this, SearchPagerFragment.class, bundle);
        }
    }
    if (SHOW_PLAYBACKFRAGMENT_ON_STARTUP.equals(intent.getAction())) {
        intent.setAction(null);
        // if this Activity is being shown after the user clicked the notification
        if (mSlidingUpPanelLayout != null) {
            mSlidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.EXPANDED);
        }
    }
    if (intent.hasExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE)) {
        intent.removeExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE);
        Bundle bundle = new Bundle();
        bundle.putInt(TomahawkFragment.CONTENT_HEADER_MODE, ContentHeaderFragment.MODE_HEADER_STATIC_SMALL);
        FragmentUtils.replace(this, PreferencePagerFragment.class, bundle);
    }

    if (intent.getData() != null) {
        final Uri data = intent.getData();
        intent.setData(null);
        List<String> pathSegments = data.getPathSegments();
        String host = data.getHost();
        String scheme = data.getScheme();
        if ((scheme != null && (scheme.equals("spotify") || scheme.equals("tomahawk"))) || (host != null
                && (host.contains("spotify.com") || host.contains("hatchet.is") || host.contains("toma.hk")
                        || host.contains("beatsmusic.com") || host.contains("deezer.com")
                        || host.contains("rdio.com") || host.contains("soundcloud.com")))) {
            PipeLine.get().lookupUrl(data.toString());
        } else if ((pathSegments != null && pathSegments.get(pathSegments.size() - 1).endsWith(".xspf"))
                || (intent.getType() != null && intent.getType().equals("application/xspf+xml"))) {
            TomahawkRunnable r = new TomahawkRunnable(TomahawkRunnable.PRIORITY_IS_INFOSYSTEM_HIGH) {
                @Override
                public void run() {
                    Playlist pl = XspfParser.parse(data);
                    if (pl != null) {
                        final Bundle bundle = new Bundle();
                        bundle.putString(TomahawkFragment.PLAYLIST, pl.getCacheKey());
                        bundle.putInt(TomahawkFragment.CONTENT_HEADER_MODE,
                                ContentHeaderFragment.MODE_HEADER_DYNAMIC);
                        new Handler(Looper.getMainLooper()).post(new Runnable() {
                            @Override
                            public void run() {
                                FragmentUtils.replace(TomahawkMainActivity.this, PlaylistEntriesFragment.class,
                                        bundle);
                            }
                        });
                    }
                }
            };
            ThreadManager.get().execute(r);
        } else if (pathSegments != null && (pathSegments.get(pathSegments.size() - 1).endsWith(".axe")
                || pathSegments.get(pathSegments.size() - 1).endsWith(".AXE"))) {
            InstallPluginConfigDialog dialog = new InstallPluginConfigDialog();
            Bundle args = new Bundle();
            args.putString(InstallPluginConfigDialog.PATH_TO_AXE_URI_STRING, data.toString());
            dialog.setArguments(args);
            dialog.show(getSupportFragmentManager(), null);
        } else {
            String albumName;
            String trackName;
            String artistName;
            try {
                MediaMetadataRetriever retriever = new MediaMetadataRetriever();
                retriever.setDataSource(this, data);
                albumName = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM);
                artistName = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST);
                trackName = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE);
                retriever.release();
            } catch (Exception e) {
                Log.e(TAG, "handleIntent: " + e.getClass() + ": " + e.getLocalizedMessage());
                new Handler(Looper.getMainLooper()).post(new Runnable() {
                    @Override
                    public void run() {
                        String msg = TomahawkApp.getContext().getString(R.string.invalid_file);
                        Toast.makeText(TomahawkApp.getContext(), msg, Toast.LENGTH_LONG).show();
                    }
                });
                return;
            }
            if (TextUtils.isEmpty(trackName) && pathSegments != null) {
                trackName = pathSegments.get(pathSegments.size() - 1);
            }
            Query query = Query.get(trackName, albumName, artistName, false);
            Result result = Result.get(data.toString(), query.getBasicTrack(),
                    UserCollectionStubResolver.get());
            float trackScore = query.howSimilar(result);
            query.addTrackResult(result, trackScore);
            Bundle bundle = new Bundle();
            List<Query> queries = new ArrayList<>();
            queries.add(query);
            Playlist playlist = Playlist.fromQueryList(IdGenerator.getSessionUniqueStringId(), "", "", queries);
            playlist.setFilled(true);
            playlist.setName(artistName + " - " + trackName);
            bundle.putString(TomahawkFragment.PLAYLIST, playlist.getCacheKey());
            bundle.putInt(TomahawkFragment.CONTENT_HEADER_MODE, ContentHeaderFragment.MODE_HEADER_DYNAMIC);
            FragmentUtils.replace(TomahawkMainActivity.this, PlaylistEntriesFragment.class, bundle);
        }
    }
}