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


Java Uri.getPort方法代码示例

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


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

示例1: deleteCertificate

import android.net.Uri; //导入方法依赖的package包/类
/**
 * Examine the existing settings for an account.  If the old host/port is different from the
 * new host/port, then try and delete any (possibly non-existent) certificate stored for the
 * old host/port.
 */
public void deleteCertificate(String newHost, int newPort, CheckDirection direction) {
    Uri uri;
    if (direction == CheckDirection.INCOMING) {
        uri = Uri.parse(getStoreUri());
    } else {
        uri = Uri.parse(getTransportUri());
    }
    String oldHost = uri.getHost();
    int oldPort = uri.getPort();
    if (oldPort == -1) {
        // This occurs when a new account is created
        return;
    }
    if (!newHost.equals(oldHost) || newPort != oldPort) {
        LocalKeyStore localKeyStore = LocalKeyStore.getInstance();
        localKeyStore.deleteCertificate(oldHost, oldPort);
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:24,代码来源:Account.java

示例2: createHost

import android.net.Uri; //导入方法依赖的package包/类
@Override
public HostBean createHost(Uri uri) {
	HostBean host = new HostBean();

	host.setProtocol(PROTOCOL);

	host.setHostname(uri.getHost());

	int port = uri.getPort();
	if (port < 0 || port > 65535)
		port = DEFAULT_PORT;
	host.setPort(port);

	String nickname = uri.getFragment();
	if (nickname == null || nickname.length() == 0) {
		host.setNickname(getDefaultNickname(host.getUsername(),
				host.getHostname(), host.getPort()));
	} else {
		host.setNickname(uri.getFragment());
	}

	return host;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:Telnet.java

示例3: createHost

import android.net.Uri; //导入方法依赖的package包/类
@Override
public HostBean createHost(Uri uri) {
	HostBean host = new HostBean();

	host.setProtocol(PROTOCOL);

	host.setHostname(uri.getHost());

	int port = uri.getPort();
	if (port < 0)
		port = DEFAULT_PORT;
	host.setPort(port);

	host.setUsername(uri.getUserInfo());

	String nickname = uri.getFragment();
	if (nickname == null || nickname.length() == 0) {
		host.setNickname(getDefaultNickname(host.getUsername(),
				host.getHostname(), host.getPort()));
	} else {
		host.setNickname(uri.getFragment());
	}

	return host;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:SSH.java

示例4: removeSession

import android.net.Uri; //导入方法依赖的package包/类
public synchronized void removeSession(Uri cred){

        for(Entry<Credential, Session> e : sessions.entrySet()){
            Uri uri = Uri.parse(e.getKey().getUriString());
            if(uri.getHost().equals(cred.getHost())&&uri.getPort()==cred.getPort()){
                boolean doNotDisconnect = false;
                for(Entry<Session, Integer> e2 : usedSessions.entrySet()){
                     if (e2.getKey() == e.getValue()) {
                         doNotDisconnect = true;
                         break;
                     }
                }
                if(!doNotDisconnect) {
                    e.getValue().disconnect();
                }
                sessions.remove(e.getKey());
            }
        }


    }
 
开发者ID:archos-sa,项目名称:aos-FileCoreLibrary,代码行数:22,代码来源:SFTPSession.java

示例5: 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];
        }
    }
    if (!CryptFactory.isCipherExisted(config.EncryptMethod)) {
        throw new Exception(String.format("Method: %s does not support", config.EncryptMethod));
    }
    config.ServerAddress = new InetSocketAddress(uri.getHost(), uri.getPort());
    return config;
}
 
开发者ID:IronMan001,项目名称:ss-android,代码行数:24,代码来源:ShadowsocksConfig.java

示例6: 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

示例7: 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

示例8: extractSmbServer

import android.net.Uri; //导入方法依赖的package包/类
/**
 * transforms '/mnt/network/smb/GROUP/SERVER/..' into 'GROUP/SERVER'
 */
public static String extractSmbServer(Uri uri) {
    if (!com.archos.filecorelibrary.Utils.isLocal(uri)) {
        //special for smb :
        //for
        /*if(uri.getScheme().equals("smb://")){
            String path = uri.toString();
            String afterSmb = path.substring(6); // "smb://".length()
            int slash = afterSmb.indexOf(File.separatorChar);
            int secondSlash = slash;
            if (slash != -1)
                secondSlash = afterSmb.indexOf(File.separatorChar, slash + 1);
            if (secondSlash != -1)
                return path.substring(0, secondSlash + 7);
            return path;

        }
        else*/
            return uri.getScheme()+"://"+uri.getHost()+(uri.getPort()!=-1?":"+uri.getPort():"");

    }
    // this should not happen but we need to return some identifier
    // results in "/mnt/network/smb" considered the smb server.
    return "";
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:28,代码来源:NetworkScannerServiceVideo.java

示例9: getSelectionArgs

import android.net.Uri; //导入方法依赖的package包/类
@Override
public void getSelectionArgs(Uri uri, Map<String, String> selection) {
	selection.put(HostDatabase.FIELD_HOST_PROTOCOL, PROTOCOL);
	selection.put(HostDatabase.FIELD_HOST_NICKNAME, uri.getFragment());
	selection.put(HostDatabase.FIELD_HOST_HOSTNAME, uri.getHost());

	int port = uri.getPort();
	if (port < 0 || port > 65535)
		port = DEFAULT_PORT;
	selection.put(HostDatabase.FIELD_HOST_PORT, Integer.toString(port));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:Telnet.java

示例10: getSelectionArgs

import android.net.Uri; //导入方法依赖的package包/类
@Override
public void getSelectionArgs(Uri uri, Map<String, String> selection) {
	selection.put(HostDatabase.FIELD_HOST_PROTOCOL, PROTOCOL);
	selection.put(HostDatabase.FIELD_HOST_NICKNAME, uri.getFragment());
	selection.put(HostDatabase.FIELD_HOST_HOSTNAME, uri.getHost());

	int port = uri.getPort();
	if (port < 0)
		port = DEFAULT_PORT;
	selection.put(HostDatabase.FIELD_HOST_PORT, Integer.toString(port));
	selection.put(HostDatabase.FIELD_HOST_USERNAME, uri.getUserInfo());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:SSH.java

示例11: 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

示例12: faviconUrl

import android.net.Uri; //导入方法依赖的package包/类
/**
 * Returns the url of the site to fetch a favicon for.
 */
private String faviconUrl() {
    String origin = mSite.getAddress().getOrigin();
    Uri uri = Uri.parse(origin);
    if (uri.getPort() != -1) {
        // Remove the port.
        uri = uri.buildUpon().authority(uri.getHost()).build();
    }
    return uri.toString();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:13,代码来源:WebsitePreference.java

示例13: 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:IronMan001,项目名称:ss-android,代码行数:15,代码来源:HttpConnectConfig.java

示例14: matches

import android.net.Uri; //导入方法依赖的package包/类
@Override
public boolean matches(IntentFirewall ifw, ComponentName resolvedComponent, Intent intent,
                       int callerUid, int callerPid, String resolvedType, int receivingUid) {
    int port = -1;
    Uri uri = intent.getData();
    if (uri != null) {
        port = uri.getPort();
    }
    return port != -1 &&
            (mLowerBound == NO_BOUND || mLowerBound <= port) &&
            (mUpperBound == NO_BOUND || mUpperBound >= port);
}
 
开发者ID:TaRGroup,项目名称:IFWManager,代码行数:13,代码来源:PortFilter.java

示例15: 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


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