当前位置: 首页>>代码示例>>Java>>正文


Java Uri.getHost方法代码示例

本文整理汇总了Java中android.net.Uri.getHost方法的典型用法代码示例。如果您正苦于以下问题:Java Uri.getHost方法的具体用法?Java Uri.getHost怎么用?Java Uri.getHost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.net.Uri的用法示例。


在下文中一共展示了Uri.getHost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onShortcutTap

import android.net.Uri; //导入方法依赖的package包/类
@Override
public void onShortcutTap(Uri uri) {
    // Build root Uri from shortcut Uri
    String rootUriString = uri.getScheme() + "://" + uri.getHost();
    if (uri.getPort() != -1) {
        rootUriString += ":" + uri.getPort();
    }
    rootUriString += "/";// important to end with "/"
    Uri rootUri = Uri.parse(rootUriString);
    Bundle args = new Bundle();
    args.putParcelable(BrowserByNetwork.CURRENT_DIRECTORY, uri);
    args.putString(BrowserByNetwork.TITLE
            , uri.getLastPathSegment());
    args.putString(BrowserByNetwork.SHARE_NAME, uri.getLastPathSegment());

    Fragment f;
    if (uri.getScheme().equals("smb")) {
        f = Fragment.instantiate(getActivity(), BrowserBySmb.class.getCanonicalName(), args);
    } else if (uri.getScheme().equals("upnp")) {
        f = Fragment.instantiate(getActivity(), BrowserByUpnp.class.getCanonicalName(), args);
    } else {
        f = Fragment.instantiate(getActivity(), BrowserBySFTP.class.getCanonicalName(), args);
    }
    BrowserCategory category = (BrowserCategory) getActivity().getSupportFragmentManager().findFragmentById(R.id.category);
    category.startContent(f);
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:27,代码来源:NewRootFragment.java

示例2: onCreate

import android.net.Uri; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_second);

    Intent intent = getIntent();
    if (intent != null) {
        Uri data = getIntent().getData();
        if (data != null) {
            String host = data.getHost();
            String path = data.getPath();
            String param = data.getQueryParameter("key1");
            String fragment = data.getFragment();
            Log.e("TAG", "host:" + host);
            Log.e("TAG", "path:" + path);
            Log.e("TAG", "param:" + param);
            Log.e("TAG", "fragment:" + fragment);
        }
    }
}
 
开发者ID:lizhangqu,项目名称:support-application,代码行数:21,代码来源:SecondActivity.java

示例3: parse

import android.net.Uri; //导入方法依赖的package包/类
public static ShadowsocksConfig parse(String proxyInfo) throws Exception{
	ShadowsocksConfig config=new ShadowsocksConfig();
    Uri uri=Uri.parse(proxyInfo);
    if(uri.getPort()==-1){
    	String base64String=uri.getHost();
    	proxyInfo="ss://"+ new String(Base64.decode(base64String.getBytes("ASCII"),Base64.DEFAULT));
    	uri=Uri.parse(proxyInfo);
    }
    
    String userInfoString=uri.getUserInfo();
    if(userInfoString!=null){
    	String[] userStrings=userInfoString.split(":");
    	config.EncryptMethod=userStrings[0];
    	if(userStrings.length>=2){
    		config.Password=userStrings[1];
    	}
    }
    config.ServerAddress=new InetSocketAddress(uri.getHost(), uri.getPort());
    config.Encryptor=EncryptorFactory.createEncryptorByConfig(config);
    return config;
}
 
开发者ID:w22ee,项目名称:onekey-proxy-android,代码行数:22,代码来源:ShadowsocksConfig.java

示例4: setChattingBackground

import android.net.Uri; //导入方法依赖的package包/类
public void setChattingBackground(String uriString, int color) {
    if (uriString != null) {
        Uri uri = Uri.parse(uriString);
        if (uri.getScheme().equalsIgnoreCase("file") && uri.getPath() != null) {
            listviewBk.setImageBitmap(getBackground(uri.getPath()));
        } else if (uri.getScheme().equalsIgnoreCase("android.resource")) {
            List<String> paths = uri.getPathSegments();
            if (paths == null || paths.size() != 2) {
                return;
            }
            String type = paths.get(0);
            String name = paths.get(1);
            String pkg = uri.getHost();
            int resId = container.activity.getResources().getIdentifier(name, type, pkg);
            if (resId != 0) {
                listviewBk.setBackgroundResource(resId);
            }
        }
    } else if (color != 0) {
        listviewBk.setBackgroundColor(color);
    }
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:23,代码来源:MessageListPanelEx.java

示例5: StreamUriFinder

import android.net.Uri; //导入方法依赖的package包/类
public StreamUriFinder(Uri uri, Context context, Looper looper){
    mUri = uri;
    mDeviceID = uri.getHost();
    abort = false;
    mContext = context;
    mUiHandler = new Handler(looper);
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:8,代码来源:StreamUriFinder.java

示例6: findDefaultTrafficStatsTag

import android.net.Uri; //导入方法依赖的package包/类
/**
 * @return The hashcode of the URL's host component, or 0 if there is none.
 */
private static int findDefaultTrafficStatsTag(String url) {
    if (!TextUtils.isEmpty(url)) {
        Uri uri = Uri.parse(url);
        if (uri != null) {
            String host = uri.getHost();
            if (host != null) {
                return host.hashCode();
            }
        }
    }
    return 0;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:Request.java

示例7: getApkDownloadPath

import android.net.Uri; //导入方法依赖的package包/类
/**
 * Get the full path for where an APK URL will be downloaded into.
 */
public static SanitizedFile getApkDownloadPath(Context context, Uri uri) {
    File dir = new File(getApkCacheDir(context), uri.getHost() + "-" + uri.getPort());
    if (!dir.exists()) {
        dir.mkdirs();
    }
    return new SanitizedFile(dir, uri.getLastPathSegment());
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:11,代码来源:ApkCache.java

示例8: onCreate

import android.net.Uri; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setResultUri(null);

    String url = getIntent().getStringExtra(EvernoteUtil.EXTRA_AUTHORIZATION_URL);
    if (TextUtils.isEmpty(url)) {
        CAT.w("no uri passed, return cancelled");
        finish();
        return;
    }

    Uri uri = Uri.parse(url);
    if (!"https".equalsIgnoreCase(uri.getScheme())) {
        CAT.w("https required, return cancelled");
        finish();
        return;
    }

    String host = uri.getHost();
    if (!HOST_EVERNOTE.equalsIgnoreCase(host) && !HOST_SANDBOX.equalsIgnoreCase(host) && !HOST_CHINA.equalsIgnoreCase(host)) {
        CAT.w("unacceptable host, return cancelled");
        finish();
        return;
    }

    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction()
            .add(android.R.id.content, new WebViewFragment())
            .commit();
    }
}
 
开发者ID:fivef,项目名称:add_to_evernote_note,代码行数:34,代码来源:EvernoteOAuthActivity.java

示例9: parse

import android.net.Uri; //导入方法依赖的package包/类
public static HttpConnectConfig parse(String proxyInfo){
	HttpConnectConfig config=new HttpConnectConfig();
    Uri uri=Uri.parse(proxyInfo);
    String userInfoString=uri.getUserInfo();
    if(userInfoString!=null){
    	String[] userStrings=userInfoString.split(":");
    	config.UserName=userStrings[0];
    	if(userStrings.length>=2){
    		config.Password=userStrings[1];
    	}
    }
    config.ServerAddress=new InetSocketAddress(uri.getHost(), uri.getPort());
    return config;
}
 
开发者ID:w22ee,项目名称:onekey-proxy-android,代码行数:15,代码来源:HttpConnectConfig.java

示例10: getTitleForDisplay

import android.net.Uri; //导入方法依赖的package包/类
/**
 * Returns a title suitable for display for a link. If |title| is non-empty, this simply returns
 * it. Otherwise, returns a shortened form of the URL.
 */
static String getTitleForDisplay(@Nullable String title, @Nullable String url) {
    if (!TextUtils.isEmpty(title) || TextUtils.isEmpty(url)) {
        return title;
    }

    Uri uri = Uri.parse(url);
    String host = uri.getHost();
    if (host == null) host = "";
    String path = uri.getPath();
    if (path == null || path.equals("/")) path = "";
    title = host + path;
    return title;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:18,代码来源:TitleUtil.java

示例11: isInternalUri

import android.net.Uri; //导入方法依赖的package包/类
public static boolean isInternalUri(Uri uri) {
    String host = uri.getHost();
    host = host != null ? host.toLowerCase() : "";
    return "tg".equals(uri.getScheme()) || "telegram.me".equals(host) || "telegram.dog".equals(host);
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:6,代码来源:Browser.java

示例12: getDomainName

import android.net.Uri; //导入方法依赖的package包/类
public static String getDomainName(@NonNull Uri uri) {
    LiCoreSDKUtils.checkNotNull(uri);
    String domain = uri.getHost();
    return domain.startsWith("www.") ? domain.substring(4) : domain;
}
 
开发者ID:lithiumtech,项目名称:li-android-sdk-core,代码行数:6,代码来源:LiUriUtils.java

示例13: init

import android.net.Uri; //导入方法依赖的package包/类
private void init(Context context, Uri incomingUri) {
    /* an URL from a click, NFC, QRCode scan, etc */
    Uri uri = incomingUri;
    if (uri == null) {
        isValidRepo = false;
        return;
    }

    Utils.debugLog(TAG, "Parsing incoming intent looking for repo: " + incomingUri);

    // scheme and host should only ever be pure ASCII aka Locale.ENGLISH
    String scheme = uri.getScheme();
    host = uri.getHost();
    port = uri.getPort();
    if (TextUtils.isEmpty(scheme) || TextUtils.isEmpty(host)) {
        errorMessage = String.format(context.getString(R.string.malformed_repo_uri), uri);
        isValidRepo = false;
        return;
    }

    if (Arrays.asList("FDROIDREPO", "FDROIDREPOS").contains(scheme)) {
        /*
         * QRCodes are more efficient in all upper case, so QR URIs are
         * encoded in all upper case, then forced to lower case. Checking if
         * the special F-Droid scheme being all is upper case means it
         * should be downcased.
         */
        uri = Uri.parse(uri.toString().toLowerCase(Locale.ENGLISH));
    } else if (uri.getPath().endsWith("/FDROID/REPO")) {
        /*
         * some QR scanners chop off the fdroidrepo:// and just try http://,
         * then the incoming URI does not get downcased properly, and the
         * query string is stripped off. So just downcase the path, and
         * carry on to get something working.
         */
        uri = Uri.parse(uri.toString().toLowerCase(Locale.ENGLISH));
    }

    // make scheme and host lowercase so they're readable in dialogs
    scheme = scheme.toLowerCase(Locale.ENGLISH);
    host = host.toLowerCase(Locale.ENGLISH);

    // We only listen for /fdroid/archive or /fdroid/repo paths when receiving a HTTP(S) intent.
    // For fdroidrepo(s) intents, we are less picky and will accept any path.
    boolean isHttpScheme = TextUtils.equals("http", scheme) || TextUtils.equals("https", scheme);
    String path = uri.getPath();
    if (path == null || isHttpScheme && !(path.contains("/fdroid/archive") || path.contains("/fdroid/repo"))) {
        isValidRepo = false;
        return;
    }

    boolean isFdroidScheme = TextUtils.equals("fdroidrepo", scheme) || TextUtils.equals("fdroidrepos", scheme);

    fingerprint = uri.getQueryParameter("fingerprint");
    bssid = uri.getQueryParameter("bssid");
    ssid = uri.getQueryParameter("ssid");
    fromSwap = uri.getQueryParameter("swap") != null;

    if (!isFdroidScheme && !isHttpScheme) {
        isValidRepo = false;
        return;
    }

    uriString = sanitizeRepoUri(uri);
    isValidRepo = true;

}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:68,代码来源:NewRepoConfig.java

示例14: callJava

import android.net.Uri; //导入方法依赖的package包/类
public static String callJava(Activity webLoader, WebView webView, String uriString) {
    String methodName = "";
    String apiName = "";
    String param = "{}";
    String port = "";
    String error;

    if (TextUtils.isEmpty(uriString)) {
        return "uri不能为空";
    }

    Uri uri = Uri.parse(uriString);
    if (uri == null) {
        return "参数不合法";
    }

    apiName = uri.getHost();
    param = uri.getQuery();
    port = uri.getPort() + "";
    methodName = uri.getPath();

    if (TextUtils.isEmpty(apiName)) {
        return "API_Name不能为空";
    }
    if (TextUtils.isEmpty(port)) {
        return "callbackId不能为空";
    }
    methodName = methodName.replace("/", "");
    if (TextUtils.isEmpty(methodName)) {
        return "handlerName不能为空";
    }

    if (uriString.contains("#")) {
        error = "参数中不能有#";
        new Callback(webView, port).apply(getFailJSONObject(error));
        return error;
    }
    if (!uriString.startsWith(EJS_SCHEME)) {
        error = "SCHEME不正确";
        new Callback(webView, port).apply(getFailJSONObject(error));
        return error;
    }

    if (exposedMethods.containsKey(apiName)) {
        HashMap<String, Method> methodHashMap = exposedMethods.get(apiName);
        if (methodHashMap != null && methodHashMap.size() != 0 && methodHashMap.containsKey(methodName)) {
            Method method = methodHashMap.get(methodName);
            if (method != null) {
                try {
                    method.invoke(null, webLoader, webView, new JSONObject(param), new Callback(webView, port));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    } else {
        //未注册API
        error = apiName + "未注册";
        new Callback(webView, port).apply(getFailJSONObject(error));
        return error;
    }
    return null;
}
 
开发者ID:dailc,项目名称:hybrid-jsbridge-simple,代码行数:64,代码来源:JSBridge.java

示例15: matches

import android.net.Uri; //导入方法依赖的package包/类
public boolean matches(final Uri resourceURI, final Uri pageURI) {
    final String path = resourceURI.getPath();

    if (path == null) {
        return false;
    }

    // We need to handle webfonts first: if they are blocked, then whitelists don't matter.
    // If they aren't blocked we still need to check domain blacklists below.
    if (blockWebfonts) {
        for (final String extension : WEBFONT_EXTENSIONS) {
            if (path.endsWith(extension)) {
                return true;
            }
        }
    }

    final String resourceURLString = resourceURI.toString();

    // Cached whitelisted items can be permitted now (but blacklisted needs to wait for the override / entity list)
    if (previouslyUnmatched.contains(resourceURLString)) {
        return false;
    }

    if (entityList != null &&
            entityList.isWhiteListed(pageURI, resourceURI)) {
        // We must not cache entityList items (and/or if we did, we'd have to clear the cache
        // on every single location change)
        return false;
    }

    final String resourceHost = resourceURI.getHost();
    final String pageHost = pageURI.getHost();

    // Whitelist first party requests.
    if (pageHost != null && pageHost.equals(resourceHost)) {
        return false;
    }

    if (previouslyMatched.contains(resourceURLString)) {
        return true;
    }

    final FocusString revhost = FocusString.create(resourceHost).reverse();

    for (final Map.Entry<String, Trie> category : categories.entrySet()) {
        if (enabledCategories.contains(category.getKey()) &&
                category.getValue().findNode(revhost) != null) {
            previouslyMatched.add(resourceURLString);
            return true;
        }
    }

    previouslyUnmatched.add(resourceURLString);
    return false;
}
 
开发者ID:mozilla-mobile,项目名称:firefox-tv,代码行数:57,代码来源:UrlMatcher.java


注:本文中的android.net.Uri.getHost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。