Download Size tracker

sergiokv

Member
Licensed User
Longtime User
Is there any lib, service or function in order to track the amout of megabytes that I download overall from the internet (wether if I'm browsing, chatting, downloading an mp3, etc)? I already looked on FTP and HTTPUtils and was not able to find something that could help me out so far.

I would appreciate any feedback.

Thanks!
Sergio
 

sergiokv

Member
Licensed User
Longtime User
Erel

Regarding this matter I found something related on the stackoverflow page ("http://stackoverflow.com/questions/263013/java-urlconnection-how-could-i-find-out-a-files-size/263037#263037")

Is it possible to use something similar in B4A to the getContentLength() function from Java?

This is the code:

private int tryGetFileSize(URL url) {
HttpURLConnection conn = null;
try {
conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("HEAD");
conn.getInputStream();
return conn.getContentLength();
} catch (IOException e) {
return -1;
} finally {
conn.disconnect();
}
}

Thanks again for your help,
Sergio
 
Upvote 0

sergiokv

Member
Licensed User
Longtime User
Thanks for the expamples and reference... I'm new and don't have much experience on this, so (if possible) could you let me know if there's any way to use those functions into B4A? Do I need to create a lib?

Thanks again for your help,
Sergio
 
Upvote 0

sergiokv

Member
Licensed User
Longtime User
Hi Tomas, it looks that this library has pretty much what I was looking for... however do you know who wrote it? I just would like to ask him about some questions regarding the intialization and the correct syntax to use it.... since I'm trying to write a simple program to track down the downloaded data from the internet but I can't find a way to compile it, this is my code (it may look nonsense but I just trying to find out how to use it)...

Sub Process_Globals

Dim tracker As NetworkMonitor
Dim g As Long

End Sub

Sub Service_Create

Dim r As String
tracker.Initialize ("r")

End Sub

Sub Service_Start (StartingIntent As Intent)

Dim g As Long
tracker.MobileRxBytes(g As Long)

End Sub

Sub Service_Destroy

End Sub


Thanks again!!
 
Upvote 0
Top