Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void getToken(){
- Thread thread = new Thread(new Runnable()
- {
- @Override
- public void run()
- {
- try
- {
- Request request = new Request.Builder()
- .url(Constants.TOKEN_URL)
- .build();
- Response response = client.newCall(request).execute();
- if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
- Headers responseHeaders = response.headers();
- for (int i = 0; i < responseHeaders.size(); i++) {
- if (responseHeaders.value(i).startsWith(Constants.TOKEN_HEADER)) {
- String cookies = responseHeaders.value(i);
- String CookieValue = null;
- if(cookies != null){
- String[] temp=cookies.split(";");
- for (String ar1 : temp ){
- if(ar1.contains(Constants.TOKEN_HEADER)){
- String[] temp1=ar1.split("=");
- CookieValue = temp1[1];
- }
- }
- }
- Log.e("Token:", CookieValue);
- String token = CookieValue;
- }
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- });
- thread.start();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement