Example usage for android.net Uri toString

List of usage examples for android.net Uri toString

Introduction

In this page you can find the example usage for android.net Uri toString.

Prototype

public abstract String toString();

Source Link

Document

Returns the encoded string representation of this URI.

Usage

From source file:Main.java

/**
 * VLC authorize only "-._~" in Mrl format, android Uri authorize "_-!.~'()*".
 * Therefore, encode the characters authorized by Android Uri when creating a mrl from an Uri.
 *//* www.  j  a v  a  2s  .c  o  m*/
public static String locationFromUri(Uri uri) {
    final char array[] = uri.toString().toCharArray();
    final StringBuilder sb = new StringBuilder(array.length * 2);

    for (final char c : array) {
        if (URI_AUTHORIZED_CHARS.indexOf(c) != -1)
            sb.append("%").append(Integer.toHexString(c));
        else
            sb.append(c);
    }

    return sb.toString();
}

From source file:Main.java

public static String encodeVLCUri(@NonNull Uri uri) {
    return encodeVLCString(uri.toString());
}

From source file:Main.java

public static Bitmap decodeUrl(Uri uri) {
    return decodeUrl(uri.toString());
}

From source file:info.papdt.blacklight.api.shorturl.ShortUrlApi.java

public static Uri expand(Uri uri) {
    String url = expand(uri.toString());
    if (TextUtils.isEmpty(url))
        return null;
    return Uri.parse(url);
}

From source file:Main.java

public static String getAbsolutePathFromNoStandardUri(Uri mUri) {
    String filePath = null;/*from   w w  w .j  a  v a  2  s .  co  m*/

    String mUriString = mUri.toString();
    mUriString = Uri.decode(mUriString);

    String pre1 = "file://" + SDCARD + File.separator;
    String pre2 = "file://" + SDCARD_MNT + File.separator;

    if (mUriString.startsWith(pre1)) {
        filePath = Environment.getExternalStorageDirectory().getPath() + File.separator
                + mUriString.substring(pre1.length());
    } else if (mUriString.startsWith(pre2)) {
        filePath = Environment.getExternalStorageDirectory().getPath() + File.separator
                + mUriString.substring(pre2.length());
    }
    return filePath;
}

From source file:info.papdt.blacklight.api.shorturl.ShortUrlApi.java

public static Uri shorten(Uri uri) {
    String url = shorten(uri.toString());
    if (TextUtils.isEmpty(url))
        return null;
    return Uri.parse(url);
}

From source file:Main.java

public static boolean isSmbVideo(Uri uri) {
    if (uri == null) {
        return false;
    }/*from w w  w  .j  a  v  a2 s  .  com*/

    String path = uri.toString();
    if (path != null && path.contains("app_smb")) {
        return true;
    } else {
        return false;
    }
}

From source file:Main.java

/**
 * decodeWithoutQuery//  w  ww  .j  av a2 s  .  c  o m
 *
 * @param uri uri
 * @return uri
 */
public static String decodeWithoutQuery(Uri uri) {
    if (uri == null) {
        return "";
    }
    String URI = uri.toString();
    return decodeWithoutQuery(URI);
}

From source file:Main.java

public static String getRealPathFromURI(Uri contentUri, Context ctx) {
    Log.d("thong", "Uri: " + contentUri.toString());

    try {/*from  w  w  w.  j a  v  a2  s  .  c  om*/
        String realpath = "";

        String[] proj = { MediaStore.Images.Media.DATA };

        //Cursor cursor = ((Activity) ctx).managedQuery(contentUri, proj, null, null, null);

        Cursor cursor = ctx.getContentResolver().query(contentUri, proj, null, null, null);

        Log.d("thong", "Column count: " + cursor.getColumnCount());

        int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);

        cursor.moveToFirst();

        realpath = cursor.getString(column_index);

        cursor.close();

        return realpath;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

From source file:Main.java

public static void writeUriAttribute(XmlSerializer out, String name, Uri value) throws IOException {
    if (value != null) {
        out.attribute(null, name, value.toString());
    }/*www.  java 2 s  .  c  o  m*/
}