本文整理匯總了Java中android.net.Uri.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java Uri.toString方法的具體用法?Java Uri.toString怎麽用?Java Uri.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.net.Uri
的用法示例。
在下文中一共展示了Uri.toString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: SFTPFile2
import android.net.Uri; //導入方法依賴的package包/類
public SFTPFile2(SftpATTRS stat, String filename, Uri uri) {
if (filename == null){
throw new IllegalArgumentException("filename cannot be null");
}
if (uri == null) {
throw new IllegalArgumentException("uri cannot be null");
}
mUriString = uri.toString();
mName = filename;
mIsDirectory = stat.isDir();
mIsFile = !stat.isDir();
mLastModified = stat.getMTime();
//TODO : permissions
mCanRead = true;
mCanWrite = true;
mLength = stat.getSize();
}
示例2: buildUrlWithLocationQuery
import android.net.Uri; //導入方法依賴的package包/類
/**
* Builds the URL used to talk to the weather server using a location. This location is based
* on the query capabilities of the weather provider that we are using.
*
* @param locationQuery The location that will be queried for.
* @return The URL to use to query the weather server.
*/
private static URL buildUrlWithLocationQuery(String locationQuery) {
Uri weatherQueryUri = Uri.parse(FORECAST_BASE_URL).buildUpon()
.appendQueryParameter(QUERY_PARAM, locationQuery)
.appendQueryParameter(FORMAT_PARAM, format)
.appendQueryParameter(UNITS_PARAM, units)
.appendQueryParameter(DAYS_PARAM, Integer.toString(numDays))
.build();
try {
URL weatherQueryUrl = new URL(weatherQueryUri.toString());
Log.v(TAG, "URL: " + weatherQueryUrl);
return weatherQueryUrl;
} catch (MalformedURLException e) {
e.printStackTrace();
return null;
}
}
示例3: addLink
import android.net.Uri; //導入方法依賴的package包/類
private void addLink(Uri uri, String title, boolean append)
{
if ((title == null) || (title.length() == 0))
title = uri.getLastPathSegment();
String url = uri.toString();
String linkText = String.format(LINK_TEMPLATE, title, url);
if (append)
textView.append(linkText);
else
{
Editable editable = textView.getEditableText();
int position = textView.getSelectionStart();
editable.insert(position, linkText);
}
loadMarkdown();
}
示例4: openIntent
import android.net.Uri; //導入方法依賴的package包/類
private void openIntent(Uri uri) {
String temp = uri.toString();
// Strip the url on '/d'
String url = Utils.parseEncryptUrl(temp);
Log.d(TAG, "openIntent: " + url);
// Open the URL using Web Browser
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
if (intent.resolveActivity(getPackageManager()) != null) {
finishAffinity();
startActivity(intent);
} else {
finishAffinity();
Toast.makeText(this, getString(R.string.error_no_app_on_device), Toast.LENGTH_SHORT).show();
}
}
示例5: buildUrlWithLatitudeLongitude
import android.net.Uri; //導入方法依賴的package包/類
/**
* Builds the URL used to talk to the weather server using latitude and longitude of a
* location.
*
* @param latitude The latitude of the location
* @param longitude The longitude of the location
* @return The Url to use to query the weather server.
*/
private static URL buildUrlWithLatitudeLongitude(Double latitude, Double longitude) {
Uri weatherQueryUri = Uri.parse(FORECAST_BASE_URL).buildUpon()
.appendQueryParameter(LAT_PARAM, String.valueOf(latitude))
.appendQueryParameter(LON_PARAM, String.valueOf(longitude))
.appendQueryParameter(FORMAT_PARAM, format)
.appendQueryParameter(UNITS_PARAM, units)
.appendQueryParameter(DAYS_PARAM, Integer.toString(numDays))
.build();
try {
URL weatherQueryUrl = new URL(weatherQueryUri.toString());
Log.v(TAG, "URL: " + weatherQueryUrl);
return weatherQueryUrl;
} catch (MalformedURLException e) {
e.printStackTrace();
return null;
}
}
示例6: handleCrop
import android.net.Uri; //導入方法依賴的package包/類
private void handleCrop(int resultCode, Intent result) {
if (resultCode == RESULT_OK) {
Uri pp=Crop.getOutput(result);
String p1=pp.toString();
p = comman.compressImage(GroupSettings.this, p1);
selectedImage = BitmapFactory.decodeFile(p);
imagePhoto.setImageBitmap(selectedImage);
encodeimage = comman.encodeTobase64(selectedImage);
updateGroup();
} else if (resultCode == Crop.RESULT_ERROR) {
Toast.makeText(this, Crop.getError(result).getMessage(), Toast.LENGTH_SHORT).show();
}
}
示例7: onReceive
import android.net.Uri; //導入方法依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
Uri uri = intent.getData();
if(uri != null){
String content = uri.toString();
AppUtils.copyToClipboard(context, content);
}
}
示例8: getFileNameFromUri
import android.net.Uri; //導入方法依賴的package包/類
private String getFileNameFromUri(Uri uri) {
String fullUri = uri.toString();
String partial_path = fullUri.split("external_files")[1];
File external_storage = Environment.getExternalStorageDirectory();
String path = external_storage.getAbsolutePath() + partial_path;
return path;
}
示例9: 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();
}
示例10: query
import android.net.Uri; //導入方法依賴的package包/類
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
switch (URI_MATCHER.match(uri)) {
case 100:
qb.setTables(DownloadAlbumTable.TABLE_NAME);
break;
case 101:
qb.setTables(DownloadVideoTable.TABLE_NAME);
break;
case 102:
qb.setTables(ThreadInfoTable.TABLE_NAME);
break;
default:
throw new IllegalStateException("Unknown URL: " + uri.toString());
}
Cursor c = qb.query(this.mDownloadDBHelper.getReadableDatabase(), projection, selection, selectionArgs, null, null, sortOrder);
if (c != null) {
c.setNotificationUri(getContext().getContentResolver(), uri);
}
return c;
}
示例11: query
import android.net.Uri; //導入方法依賴的package包/類
@Override
public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
String[] columnNames = (projection == null) ? DEFAULT_PROJECTION : projection;
List<String> segments = uri.getPathSegments();
String accountUuid = segments.get(0);
String id = segments.get(1);
final AttachmentInfo attachmentInfo;
try {
final Account account = Preferences.getPreferences(getContext()).getAccount(accountUuid);
attachmentInfo = LocalStore.getInstance(account, getContext()).getAttachmentInfo(id);
} catch (MessagingException e) {
Timber.e(e, "Unable to retrieve attachment info from local store for ID: %s", id);
return null;
}
if (attachmentInfo == null) {
Timber.d("No attachment info for ID: %s", id);
return null;
}
MatrixCursor ret = new MatrixCursor(columnNames);
Object[] values = new Object[columnNames.length];
for (int i = 0, count = columnNames.length; i < count; i++) {
String column = columnNames[i];
if (AttachmentProviderColumns._ID.equals(column)) {
values[i] = id;
} else if (AttachmentProviderColumns.DATA.equals(column)) {
values[i] = uri.toString();
} else if (AttachmentProviderColumns.DISPLAY_NAME.equals(column)) {
values[i] = attachmentInfo.name;
} else if (AttachmentProviderColumns.SIZE.equals(column)) {
values[i] = attachmentInfo.size;
}
}
ret.addRow(values);
return ret;
}
示例12: getAllBranchesURL
import android.net.Uri; //導入方法依賴的package包/類
public static String getAllBranchesURL() {
Uri uri = Uri.parse(BASE_URL_API)
.buildUpon()
.appendPath("Branch")
//.appendPath("all")
.build();
Log.i("Get All Branches URL" , uri.toString());
return uri.toString();
}
示例13: createOAuthService
import android.net.Uri; //導入方法依賴的package包/類
protected static OAuthService createOAuthService(BootstrapProfile bootstrapProfile, String consumerKey, String consumerSecret) {
String host = bootstrapProfile.getSettings().getServiceHost();
if (host == null) {
return null;
}
Uri uri = new Uri.Builder()
.authority(host)
.scheme("https")
.build();
Class<? extends Api> apiClass;
switch (uri.toString()) {
case EvernoteSession.HOST_SANDBOX:
apiClass = EvernoteApi.Sandbox.class;
break;
case EvernoteSession.HOST_PRODUCTION:
apiClass = EvernoteApi.class;
break;
case EvernoteSession.HOST_CHINA:
apiClass = EvernoteApi.Yinxiang.class;
break;
default:
throw new IllegalArgumentException("Unsupported Evernote host: " + host);
}
return new ServiceBuilder()
.provider(apiClass)
.apiKey(consumerKey)
.apiSecret(consumerSecret)
.callback(CALLBACK_SCHEME + "://callback")
.build();
}
示例14: getType
import android.net.Uri; //導入方法依賴的package包/類
@Override
@Nullable
public String getType(@NonNull Uri uri) {
switch (sUriMatcher.match(uri)) {
case Code.ALL_USERS:
return ContentType.ALL_USERS;
case Code.SINGLE_USER:
return ContentType.SINGLE_USER;
default:
throw new IllegalArgumentException("Unsupported URI: " + uri.toString());
}
}
示例15: makeEntryForURL
import android.net.Uri; //導入方法依賴的package包/類
public static JSONObject makeEntryForURL(LocalFilesystemURL inputURL, Uri nativeURL) {
try {
String path = inputURL.path;
int end = path.endsWith("/") ? 1 : 0;
String[] parts = path.substring(0, path.length() - end).split("/+");
String fileName = parts[parts.length - 1];
JSONObject entry = new JSONObject();
entry.put("isFile", !inputURL.isDirectory);
entry.put("isDirectory", inputURL.isDirectory);
entry.put("name", fileName);
entry.put("fullPath", path);
// The file system can't be specified, as it would lead to an infinite loop,
// but the filesystem name can be.
entry.put("filesystemName", inputURL.fsName);
// Backwards compatibility
entry.put("filesystem", "temporary".equals(inputURL.fsName) ? 0 : 1);
String nativeUrlStr = nativeURL.toString();
if (inputURL.isDirectory && !nativeUrlStr.endsWith("/")) {
nativeUrlStr += "/";
}
entry.put("nativeURL", nativeUrlStr);
return entry;
} catch (JSONException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}