-1

How can I check if an URL exists and, if yes, do something? I'm making an app that get updates from a private server (HTTP). What I want to do is the following:

1) Check if the URL exists.

2) If response is positive, then display a dialog that let you download the update.

3) If response is negative, then display a dialog which tells you that the current version installed is the latest.

I wrote a little code that download the update from the server but it doesn't check if the URL exists. In fact, it tries to "download" the update also when the new APK isn't on the server (so it downloads nothing). Can someone help me with this? Thanks in advance.

Chaoz
  • 2,119
  • 1
  • 20
  • 39
peppe130
  • 1
  • 1
  • possible duplicate of [How to check if a URL exists or returns 404 with Java?](http://stackoverflow.com/questions/1378199/how-to-check-if-a-url-exists-or-returns-404-with-java) – Shrikant Havale May 30 '15 at 19:41

2 Answers2

0

Hello it's easy: you will get an Exception if the url does not exist

Ilja KO
  • 1,272
  • 12
  • 26
0

So in the exception I should write strings for a Toast message (for example a Toast in which is wrote "You'are using the latest version of this app").. And how to display a dialog if the URL exists?

peppe130
  • 1
  • 1