Problems using scanner to get url content to a string in Android

Question

I'm trying to copy url contents with user info. First, the user log in and then the page show the user info. I want to copy that info to a String. I am using this:

try {
    variable1 = new Scanner(new URL("https://example.com/hello").openStream(), "UTF-8").useDelimiter("\\A").next();
}catch (MalformedURLException e) {
    System.out.println("The URL is not valid.");
}catch (IOException e) {
    System.out.println("The URL is not valid.");
}

But I am getting the content in the login page...(as the user never logged in).


Show source
| url   | webview   | android   | string   | convert   2017-01-03 15:01 1 Answers

Answers ( 1 )

  1. 2017-01-03 16:01

    I thing maybe missing the cookie id in the request header. The cookie id is in the header of the response after the login request finished.

◀ Go back