當前位置: 首頁>>代碼示例>>Java>>正文


Java Uri.toString方法代碼示例

本文整理匯總了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();
}
 
開發者ID:archos-sa,項目名稱:aos-FileCoreLibrary,代碼行數:19,代碼來源:SFTPFile2.java

示例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;
    }
}
 
開發者ID:fjoglar,項目名稱:android-dev-challenge,代碼行數:25,代碼來源:NetworkUtils.java

示例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();
}
 
開發者ID:billthefarmer,項目名稱:diary,代碼行數:21,代碼來源:Diary.java

示例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();
    }
}
 
開發者ID:rumaan,項目名稱:file.io-app,代碼行數:19,代碼來源:DownloadActivity.java

示例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;
    }
}
 
開發者ID:fjoglar,項目名稱:android-dev-challenge,代碼行數:27,代碼來源:NetworkUtils.java

示例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();
     }
 }
 
開發者ID:mityung,項目名稱:XERUNG,代碼行數:15,代碼來源:GroupSettings.java

示例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);
    }
}
 
開發者ID:ThirtyDegreesRay,項目名稱:OpenHub,代碼行數:9,代碼來源:CopyBroadcastReceiver.java

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

}
 
開發者ID:Andy-Ta,項目名稱:COB,代碼行數:9,代碼來源:CordovaUri.java

示例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();
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:13,代碼來源:WebsitePreference.java

示例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;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:22,代碼來源:DownloadProvider.java

示例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;
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:41,代碼來源:AttachmentProvider.java

示例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();
}
 
開發者ID:ayounes3333,項目名稱:GSB-2017-Android,代碼行數:10,代碼來源:UrlManager.java

示例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();
}
 
開發者ID:fivef,項目名稱:add_to_evernote_note,代碼行數:37,代碼來源:EvernoteOAuthHelper.java

示例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());
    }
}
 
開發者ID:TigranSarkisian,項目名稱:Boilerplate,代碼行數:15,代碼來源:TlProvider.java

示例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);
    }
}
 
開發者ID:rodrigonsh,項目名稱:alerta-fraude,代碼行數:30,代碼來源:Filesystem.java


注:本文中的android.net.Uri.toString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。