Example usage for android.net Uri getLastPathSegment

List of usage examples for android.net Uri getLastPathSegment

Introduction

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

Prototype

@Nullable
public abstract String getLastPathSegment();

Source Link

Document

Gets the decoded last segment in the path.

Usage

From source file:Main.java

public static String getStreamIDFromPlayoutURI(Uri uri) {
    return uri.getLastPathSegment();
}

From source file:Main.java

public static long extractId(Uri serieUri) {
    return Long.parseLong(serieUri.getLastPathSegment());
}

From source file:Main.java

public static String parseUriToName(String url) {
    Uri uri = Uri.parse(url);
    String name = uri.getLastPathSegment();
    return name;/*from ww  w  .j  a  v  a 2  s.  c o  m*/
}

From source file:Main.java

/**
 * Activities on Android are invoked with a Uri string.  This method captures and returns the last bit of this Uri
 * which it assumes to be a numeric ID of the current article/announcements etc.
 * @return/*from w  w w .j  a  v  a2s. com*/
 */
public static int filterIdFromUri(Uri uri) {
    String id = uri.getLastPathSegment();

    return Integer.valueOf(id);
}

From source file:Main.java

public static boolean isTempPic(Uri paramUri) {
    return (paramUri != null) && (paramUri.getLastPathSegment() != null)
            && (paramUri.getLastPathSegment().startsWith("pic-"));
}

From source file:Main.java

public static String getTweetId(String in) {

    if (TextUtils.isEmpty(in)) {
        return null;
    }//w w  w. ja v  a  2 s.c  om

    if (in.indexOf("twitter") >= 0 || in.indexOf("t.co") >= 0) {

        Uri tweet = Uri.parse(in);

        String lastPath = tweet.getLastPathSegment();
        if (TextUtils.isEmpty(lastPath) == false && TextUtils.isDigitsOnly(lastPath)) {
            return lastPath;
        }
    }
    return null;
}

From source file:Main.java

public static String getYouTubeIdFromIdOrUrl(String idOrUrl) {
    Uri uri = Uri.parse(idOrUrl);
    if (uri.getScheme() != null) {
        return uri.getLastPathSegment();
    } else {//from   w w  w  .ja  v  a  2s .  c  om
        return idOrUrl;
    }
}

From source file:Main.java

public static String geVideotName(Activity activity, Uri uri) throws Exception {

    String[] projection = { MediaStore.Video.Media.DATA };
    Cursor cursor = activity.managedQuery(uri, projection, null, null, null);
    activity.startManagingCursor(cursor);
    int column_index = cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA);
    cursor.moveToFirst();/*  ww w  .j  a v  a2 s.c o  m*/
    Uri filePathUri = Uri.parse(cursor.getString(column_index));
    String file_name = filePathUri.getLastPathSegment().toString();
    return file_name;
}

From source file:Main.java

public static String getName(Activity activity, Uri uri) {

    String[] projection = { MediaStore.Images.Media.DATA };
    Cursor cursor = activity.managedQuery(uri, projection, null, null, null);
    activity.startManagingCursor(cursor);
    int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
    cursor.moveToFirst();//from w w w. j av a  2s  .  c  om
    Uri filePathUri = Uri.parse(cursor.getString(column_index));
    String file_name = filePathUri.getLastPathSegment().toString();
    return file_name;
}

From source file:Main.java

public static List<String> getAllTables(Uri uri) {
    List<String> result = new ArrayList<String>();

    String mainTable = uri.getLastPathSegment();
    result.add(mainTable);/*  w w  w. ja v a 2  s .  c o m*/

    Set<String> queryParameterNames = uri.getQueryParameterNames();
    Iterator<String> iterator = queryParameterNames.iterator();
    while (iterator.hasNext()) {
        String table = iterator.next();
        if (table.startsWith(TABLE)) {
            result.add(table.replaceFirst(TABLE, ""));
        }
    }
    return result;
}