From what I read, unlimited mobile download plans are disappearing. I think Sprint might have one of the only ones left.
For an Android app that makes frequent Internet downloads, is there any way to measure -- and possibly cap -- the cumulative amount of data downloaded?
You should find an implementation for this:
A very simple example
public class DownloadSherif{
private static int MAX_DOWNLOAD_PER_DAY = 999;
private int last_24_hours_downloaded;
public DownloadSherif(){
//get last_24_hours_downloaded from saved container
}
public boolean canDownload(int download_size){
if((download_size+last_24_hours_downloaded)<=MAX_DOWNLOAD_PER_DAY)
return true;
else
return false;
}
public void downloaded(int just_downloaded){
last_24_hours_downloaded += just_downloaded;
}
}
Now every time you want to download you must ask permission using canDownload
Final Notes
in the last X hours
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.