本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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());
}
}
}
示例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;
}
示例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);
}
示例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;
}
示例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 "";
}
示例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));
}
示例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());
}
示例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());
}
示例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();
}
示例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;
}
示例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);
}
示例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;
}