Hello i have an URL i get from the Server:
What i need now is from the Query to get the "code" which is this part 11448259-7efe-4c6e-bbce-216bb8578bd5, how to i split this String so to get only the code or other parameters using Java.
Hello i have an URL i get from the Server:
What i need now is from the Query to get the "code" which is this part 11448259-7efe-4c6e-bbce-216bb8578bd5, how to i split this String so to get only the code or other parameters using Java.
You can use the following code to get the value for query param code
.
String url = "http://localhost.osc-ref.dockercloud.fiducia.de/login?code=11448259-7efe-4c6e-bbce-216bb8578bd5&scope=openid&iss=https%3A%2F%2Fr8840-e40-e.t1.web.fiducia.de%3A443%2Fservices_my-account%2Foauth2%2FXC8840&state=myScope&client_id=fkp";
Uri uri = Uri.parse(url);
String code = uri.getQueryParameter("code");
Log.e("Value for query-param:", code);
Try this,
import org.apache.hc.client5.http.utils.URLEncodedUtils
String url = "http://www.example.com/something.html?
one=1&two=2&three=3&three=3a";
List<NameValuePair> params = URLEncodedUtils.parse(new URI(url),
Charset.forName("UTF-8"));
for (NameValuePair param : params) {
System.out.println(param.getName() + " : " + param.getValue());
}