I want to manage download in my android app such that if network connection is lost i would like to stop download automatically informing user and start download when connection is available? is it possible in android? if it is, can anyone guide me?
Asked
Active
Viewed 850 times
0
-
If the connection throws an Exception when it fails, then catch the Exception and report to the user. Alternatively, Google for the Android connectivity notifications and read this answer - http://stackoverflow.com/questions/2294971/intent-action-for-network-events-in-android-sdk. – Paul Grime Sep 19 '11 at 08:51
-
thanks paul for ur useful link – Krishna Shrestha Sep 20 '11 at 09:44
1 Answers
2
HttpResponse response = httpclient.execute(httppost);
StatusLine statusline = response.getStatusLine();
if(statuscode == 200)
{connection established }
else no connection
IF you are usuing http then this standard way to check you connection and when catch an exception while downloading then set flag where did you stoped last and check after some time whether connnection is available or not using broadcast reciever or service and prompt user to download agian or you also start automatically download.
i know this is very vague answer but this is just process to follow if you want in more detail just paste your code snippet of downloading proces. thank you.

School Boy
- 1,207
- 2
- 19
- 33