public class HttpUtil {
/***
* 获取url 指定name的value;
* @param url
* @param name 工具类
* @return
*/
public static String getValueByName(String url, String name) {
String result = “”;
int index = url.indexOf(“?”);
String parameters = url.substring(index + 1);
String[] keyValue = parameters.split(“&”);
for (String str : keyValue) {
if (str.contains(name)) {
result = str.replace(name + “=”, “”);
break;
}
}
return result;
}
}
activity中调用 ,json格式给到接口就行了 (当然看后端接口要求)->
JSONObject jsonObject = new JSONObject();
jsonObject.put(“videoId”, HttpUtil.getValueByName(webUrl, “videoId”));
jsonObject.put(“currentIndex”, HttpUtil.getValueByName(webUrl, “currentIndex”));
sonObject.toJSONString()