I open a connect like this:
URL mUrl = new URL("http://www.abc.com/4MB.mp3");
URLConnection conn = mUrl.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
FileOutputStream fos = new FileOutputStream(tmpFile);
byte[] readBody = new byte[4096];
do {
int readBytes = is.read(readBody);
if (readBytes <= 0) {
break;
}
fos.write(readBody, 0, readBytes);
}while(true);
I have two question
(1) How to cancel the connection when conn.connect() is executed ? I
can not find any useful API from
http://developer.android.com/reference/java/net/URLConnection.html
(2) When user cancel this activity, I use is.close() to cancel the
is.read(). Is that a good way to cancel InputStream ? and how to handle
(cancel) the conn this moment ?
Best Regards,
Brad
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---