android 获取url中的参数

/***
     * 获取url 指定name的value;
     * @param url
     * @param name
     * @return
     */
    private String getValueByName(String url, String name) {
        String result = "";
        int index = url.indexOf("?");
        String temp = url.substring(index + 1);
        String[] keyValue = temp.split("&");
        for (String str : keyValue) {
            if (str.contains(name)) {
                result = str.replace(name + "=", "");
                break;
            }
        }
        return result;
    }
发布了53 篇原创文章 · 获赞 17 · 访问量 9万+

猜你喜欢

转载自blog.csdn.net/qq910689331/article/details/80004159