本文整理匯總了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;
}