P
P
Pavel Dmitriev2013-12-28 12:17:10
Java
Pavel Dmitriev, 2013-12-28 12:17:10

How to prescribe the check of the link address in the condition and add it to the list?

I'm sorry if this is a stupid question, I'm just learning.
I need to fulfill such a condition
If the link " example.ru "+ nick.getText().toString() +".png" is correct, then add nick.getText().toString() to the list list view, otherwise do not add.
nick.getText().toString() is the player's nickname received in the edittext input field and should be added to the list if such a nickname exists.
for more details, where does the nickname come from here How to generate a link from the input field?
Advise in which direction to dig and what will I need to implement this condition?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
svd71, 2013-12-28
@svd71

towards parsing the response header.
either you have a bad example (there is nothing on the specified site except for the adblock) or I still don’t understand what you want.
If you want to check if a site is actually returning an image, it's best to look at the response header. There should be information "Content-type: image/png".

T
tsarevfs, 2013-12-28
@tsarevfs

public static int getResponseCode(String urlString) throws MalformedURLException, IOException {
    URL u = new URL(urlString); 
    HttpURLConnection huc =  (HttpURLConnection)  u.openConnection(); 
    huc.setRequestMethod("HEAD"); 
    huc.connect(); 
    return huc.getResponseCode();
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question