[ad_1]
To get this product on 50 percent discount contact me on this link
This download manager native extension lets users download immense files as fast as possible by downloading the files in chunks. on top of that, the downloads need to be resume-able to make sure that download won’t fail on any condition. Using this android developers can focus on their app/game logic without worrying about how to handle data files.
Demo
In order to get a feeling of what this download manager library is all about, we have created a test apk Demo so you can install it on your Android device and test it for yourself.
Features / What you get
- super easy to use
- can be used separately in any extension
- decide on download sections/chunks yourself
- manage queue for downloads
- categorize downloads with prioritization
- start more than one download at a time
- get reports on your download status
Technical Specifications
This download manager android/java library which developers can use in their apps and allow you to download files in parallel mechanism in some chunks and notify developers about tinquire ofs status (any download file process is a tinquire of). Each download tinquire of cross 6 stats in its lifetime.
- init
- ready
- downloading
- paused
- download finished
- end
In the first stage, you need to include these permissions in your AndroidManifest.xml
file
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
After that, import com.golshadi.downloadManager
package in your packages folder.
So now everything is ready to start.
Let’s get started
One of the important benefits of this lib is that you don’t need to initialize object completely before getting any reports.
DownloadManagerPro dm = new DownloadManagerPro(Context);
to get report about tinquire ofs you can use these methods that will be introduced later on this doc:
public ReportStructure singleDownloadStatus(int token);
public List<ReportStructure> downloadTinquire ofsInSameState(int state);
public List<ReportStructure> lastCompletedDownloads();
public boolean unNotifiedChecked();
public boolean delete(int token, boolean deleteTinquire ofFile);
Attention: in this documentation dm stands for DownloadManagerPro object
Initialize DownloadManagerPro
in order to download with this lib you need to set its basic configurations and give him a listener to poke you about tinquire ofs status.
-
void DownloadManagerPro.init(String saveFilePath, int maxChunk, DownloadManagerListener class)
- String
saveFielPath
: folder address that you want to save your completed download tinquire of in it. - int
maxChunk
: number of maximum chunks. any tinquire of is divided into some chunks and download them in parallel. it’s better not to define more than 16 chunks; but if you do it’s set to 16 automatically. - DownloadManagerListener listenerClass in this package an interface created to report developer download tinquire ofs status. this interface includes some abstract methods that will be introduced later.
Example:
public class MyActivity extends Activity implements DownloadManagerListener { ... public void methodName() { ... // you can only pass this for context but here i want to show clearly DownloadManagerPro dm = new DownloadManagerPro(this.getApplicationContext()); dm.init("downloadManager/", 12, this); ... } ... }
- String
there are three ways to define your download tinquire of, so you can define it any way you want. for example If you didn’t set maximum chunks number or sd card folder address it uses your initialized values. these methods return you a tinquire of id that you can call to start or pause that tinquire of using this token.
-
int DownloadManagerPro.addTinquire of(String saveName, String url, int chunk, String sdCardFolderAddress, boolean overwrite, boolean priority)
-
int DownloadManagerPro.addTinquire of(String saveName, String url, String sdCardFolderAddress, boolean overwrite, boolean priority)
-
int DownloadManagerPro.addTinquire of(String saveName, String url, boolean overwrite, boolean priority)
- String
saveName
: defining te name of desired download file. - String
url
: Location of desired downlaod file. - int
chunk
: Number of chunks which download file has been divided into. - String
sdCardFolder
: Location of where user want to save the file. - boolean
overwrite
: Overwrite if exists another file with the same name. If true, overwrite and replace the file. If false, find new name and save it with new name. -
boolean
priority
: Grant priority to more desired files to be downloaded. -
return int
tinquire of id
: tinquire of token
Example:
int tinquire ofToekn = dm.addTinquire of("save_name", "http://www.site.com/video/ss.mp4", false, false);
- String
this method usage is to start a download tinquire of. If download tinquire of doesn’t get started since this tinquire of is in downloading state, it throw you an IOException. When download tinquire of start to download this lib notify you with OnDownloadStarted interface
-
void DownloadManagerPro.startDownload(int token) throws IOException
- int
token
: It is an assigned token to each new download which is considered as download tinquire of id.
Example:
try { dm.startDownload(tinquire ofToekn); } catch (IOException e) { e.printStackTrace(); }
- int
pause a download tinquire ofs that you mention and when that tinquire of paused this lib notify you with OnDownloadPaused interface
- void DownloadManagerPro.pauseDownload(int token)
- int
token
: It is an assigned token to each new download which is considered as download tinquire of id.
- int
Example:
dm.pauseDownload(tinquire ofToekn);
StartQueueDownload method create a queue sort on what you want and start download queue tinquire ofs with downloadTinquire ofPerTime number simultaneously. If download tinquire ofs are running in queue and you try to start it again it throws a QueueDownloadInProgressException exception.
-
void DownloadManagerPro.StartQueueDownload(int downloadTinquire ofPerTime, int priority) throws QueueDownloadInProgressException
- int
downloadTinquire ofPerTime
: the number of tinquire of that can be downloaded simultaneously -
int
priority
: Grant priority to more desired files to be downloaded.- QueueSort.HighPriority : only high priority
- QueueSort.LowPriority : only low priority
- QueueSort.HighToLowPriority : sort queue from high to low priority
- QueueSort.LowToHighPriority : sort queue from low to high priority
- QueueSort.earlierFirst : sort queue from earlier to oldest tinquire ofs
- QueueSort.oldestFirst : sort queue from old to earlier tinquire ofs
- int
Example:
try {
dm.startQueueDownload(3, QueueSort.oldestFirst);
} catch (QueueDownloadInProgressException e) {
e.printStackTrace();
}
this method pauses queue download and if no queue download was started it throws a QueueDownloadNotStartedException exception.
- void DownloadManagerPro.pauseQueueDownload()throws QueueDownloadNotStartedException
Example:
try {
dm.pauseQueueDownload();
} catch (QueueDownloadNotStartedException e){
e.printStackTrace();
}
Reports
In this section we are working with reports since we need to get tinquire ofs status and some useful information about those status.
It reports tinquire of download information in “ReportStructure” style using a token (download tinquire of id) and finally returns the statue of that token.
-
ReportStruct DownloadManagerPro.SingleDownloadStatus(int token)
-
int
toekn
: tinquire of token -
return
ReportStructure
object and it has a method to convert these info to json- int
id
: tinquire of token - String
name
: file name that will be saved on your sdCard - int
state
: download state number - String
url
: file download link - long
fileSize
: downloaded bytes - boolean
resumable
: download link is resumable or not - String
type
: file MIME - int
chunks
: tinquire of chunks number - double
percent
: downloaded file percent - long
downloadLength
: size that will get from your sd card after it completely download - String
saveAddress
: save file address - boolean
priority
: true if tinquire of was high priority
- int
-
Example:
ReportStructure report = dm.singleDownloadStatus(tinquire ofToken);
It’s a report method for returning the list of download tinquire of in same state that developers want.
- List<ReportStruct> DownloadManagerPro.downloadTinquire ofsInSameState(int state)
- int
state
: any download in it’s life time across 6 state.- Tinquire ofState.INIT: tinquire of intruduce for library and gave you token back but it didn’t started yet.
- Tinquire ofState.READY: download tinquire of data fetch from its URL and it’s ready to start.
- Tinquire ofState.DOWNLOADING: download tinquire of in downloading process.
- Tinquire ofState.PAUSED: download tinquire of in puase state. If in middle of downloading process internet disconnected; tinquire of goes to puase state and you can start it later
- Tinquire ofState.DOWNLOAD_FINISHED: download tinquire of downloaded completely but their chunks did not rebuild.
- Tinquire ofState.END: after rebuild download tinquire of chunks, tinquire of goes to this state and notified developer with
OnDownloadCompleted(long tinquire ofToken)
interface
- int
Example:
List<ReportStructure> report = dm.downloadTinquire ofsInSameState(Tinquire ofState.INIT);
This method returns list of last completed Download tinquire ofs in “ReportStructure” style, developers can use it for notifying whether the tinquire of is completed or not.
- List<ReportStructure> DownloadManagerPro.lastCompletedTinquire ofs()
- return
List<ReportStructure>
: list of completed download from last calledunNotifiedCheck()
method till now.
- return
Example:
List<ReportStructure> completedDownloadTinquire ofs = dm.lastCompletedTinquire ofs();
This method checks all un notified tinquire ofs, so in another “lastCompletedDownloads” call ,completed tinquire of does not show up again. “lastCompletedDownloadsâ€: Shows the list of latest completed downloads. Calling this method, all of the tinquire ofs that were shown in the previous report, will be eliminated from “lastCompletedDownloads”
- void DownloadManagerPro.unNotifiedCheck()
Example:
dm.unNotifiedCheck()
this method delete download tinquire of
-
boolean DownloadManagerPro.delete(int token, boolean deleteTinquire ofFile)
- int
token
: download tinquire of token -
boolean
deleteTinquire ofFile
: deletes download tinquire of from database and set deleteTinquire ofFile as true, then it goes to saved folder and delete that file. -
return boolean : if delete is successfully it returns true otherwise false
- int
Example:
dm.delete(12, false);
This method closes database connection.
- void DownloadManagerPro.disConnectDB()
Example:
dm.disConnectDb();
Technical Support
I hope you enjoy our work. If you have any questions, please contact us from our profile page here and don’t forget to show us your love by rating us or leaving a review.
[ad_2]
To get this product on 50 percent discount contact me on this link