当前位置: 首页>>代码示例>>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;未经允许,请勿转载。