Monday, January 2, 2017

Obtain Manager Android/Java Library


This download manager local extension we could customers obtain big information as fast as imaginable by means of downloading the recordsdata in chunks. on top of that, the downloads need to be resume-able to make sure that that download won’t fail on any condition. The Use Of this android builders can take care of their app/sport common sense without worrying approximately the best way to handle information information.

Demo

So As to get a sense of what this obtain supervisor library is all about, we now have created a check apk Demo so that you can install it in your Android tool and check it for your self.

Options / What you get

  • tremendous easy to make use of
  • will also be used separately in any extension
  • settle on download sections/chunks yourself
  • handle queue for downloads
  • categorize downloads with prioritization
  • get started greater than one download at a time
  • get reports for your obtain status

Technical Specifications

This download manager android/java library which developers can use in their apps and make allowance you to download information in parallel mechanism in some chunks and notify builders about duties status (any download record process is a role). Each And Every obtain activity cross 6 stats in its lifetime.

  1. init
  2. ready
  3. downloading
  4. paused
  5. download finished
  6. end

Screenshot

in the first stage, you need to come with these permissions in your AndroidManifest.xml record

<uses-permission android:identify="android.permission.INTERNET" /> <uses-permission android:identify="android.permission.WRITE_EXTERNAL_STORAGE"/>

After that, import com.golshadi.downloadManager bundle for your packages folder. So now the whole lot is ready to start out.

Permit’s get started

certainly one of the real benefits of this lib is that you just don’t want to initialize object completely earlier than getting any reports.

DownloadManagerPro dm = new DownloadManagerPro(Context);

to get report about tasks you'll use these methods so that it will be offered later on this doc:

public ReportStructure singleDownloadStatus(int token); public Checklist<ReportStructure> downloadTasksInSameState(int state); public List<ReportStructure> lastCompletedDownloads(); public boolean unNotifiedChecked(); public boolean delete(int token, boolean deleteTaskFile);

Attention: on this documentation dm stands for DownloadManagerPro object

Initialize DownloadManagerPro

so as to obtain with this lib you want to set its fundamental configurations and give him a listener to poke you approximately duties status.

  • void DownloadManagerPro.init(String saveFilePath, int maxChunk, DownloadManagerListener elegance)

    • String saveFielPath: folder cope with that you simply want to save your completed obtain activity in it.
    • int maxChunk : number of maximum chunks. any task is divided into a few chunks and download them in parallel. it’s higher to not outline greater than SIXTEEN chunks; but if you do it’s set to SIXTEEN robotically.
    • DownloadManagerListener listenerClass on this package an interface created to report developer download duties status. this interface comprises a few summary strategies so that you can be presented later.

    Example:

    public elegance MyActivity extends Activity implements DownloadManagerListener ... public void methodName()

there are three ways to outline your download activity, so that you can outline it any manner you need. for example if you didn’t set maximum chunks number or sd card folder deal with it uses your initialized values. these methods go back you a task identity that you'll call to start out or pause that task the use of this token.

  • int DownloadManagerPro.addTask(String saveName, String url, int chew, String sdCardFolderAddress, boolean overwrite, boolean priority)

  • int DownloadManagerPro.addTask(String saveName, String url, String sdCardFolderAddress, boolean overwrite, boolean priority)

  • int DownloadManagerPro.addTask(String saveName, String url, boolean overwrite, boolean priority)

    • String saveName: defining te identify of desired obtain report.
    • String url : Location of favored downlaod file.
    • int bite : choice of chunks which obtain report has been divided into.
    • String sdCardFolder : Location of the place user wish to retailer the record.
    • boolean overwrite : Overwrite if exists any other record with the similar identify. If real, overwrite and change the record. If fake, find new title and reserve it with new name.
    • boolean priority : Provide precedence to extra desired information to be downloaded.

    • go back int process id: job token

    Instance:

    int taskToekn = dm.addTask("save_name", "http://www.site.com/video/ss.mp4", false, false);

this technique usage is to begin a obtain activity. If obtain task doesn’t get started given that this job is in downloading state, it throw you an IOException. Whilst download process begin to obtain this lib notify you with OnDownloadStarted interface

  • void DownloadManagerPro.startDownload(int token) throws IOException

    • int token: it is an assigned token to each new obtain which is considered as download task identification.

    Instance:

    take a look at dm.startDownload(taskToekn); trap (IOException e) e.printStackTrace();

pause a obtain duties that you simply mention and while that process paused this lib notify you with OnDownloadPaused interface

  • void DownloadManagerPro.pauseDownload(int token)
    • int token: it is an assigned token to each new download that is regarded as download process identification.

Instance:

dm.pauseDownload(taskToekn);

StartQueueDownload way create a queue sort on what you wish to have and begin download queue duties with downloadTaskPerTime number concurrently. If obtain duties are running in queue and you try to begin it once more it throws a QueueDownloadInProgressException exception.

  • void DownloadManagerPro.StartQueueDownload(int downloadTaskPerTime, int priority) throws QueueDownloadInProgressException

    • int downloadTaskPerTime: the choice of job that can be downloaded concurrently
    • int precedence: Furnish priority to more desired recordsdata to be downloaded.

      • QueueSort.HighPriority : simplest top priority
      • QueueSort.LowPriority : handiest low precedence
      • QueueSort.HighToLowPriority : kind queue from top to low priority
      • QueueSort.LowToHighPriority : sort queue from low to high priority
      • QueueSort.earlierFirst : kind queue from earlier to oldest duties
      • QueueSort.oldestFirst : sort queue from vintage to in advance duties

Example:

take a look at dm.startQueueDownload(3, QueueSort.oldestFirst); capture (QueueDownloadInProgressException e) e.printStackTrace();

this system pauses queue download and if no queue obtain was started it throws a QueueDownloadNotStartedException exception.

  • void DownloadManagerPro.pauseQueueDownload()throws QueueDownloadNotStartedException

Instance:

take a look at dm.pauseQueueDownload(); capture (QueueDownloadNotStartedException e) e.printStackTrace();

Reviews

On This segment we are working with stories when you consider that we want to get duties status and a few useful information about those status.

It stories job download information in “ReportStructure” style the usage of a token (download task id) and at last returns the statue of that token.

  • ReportStruct DownloadManagerPro.SingleDownloadStatus(int token)

    • int toekn: job token

    • return ReportStructure item and it has a method to convert those data to json

      • int id: task token
      • String title: document title so they can be stored in your sdCard
      • int state: download state quantity
      • String url: document download hyperlink
      • lengthy fileSize: downloaded bytes
      • boolean resumable: download link is resumable or not
      • String type: file MIME
      • int chunks: job chunks number
      • double p.c: downloaded file %
      • long downloadLength: dimension so that you can get out of your sd card after it completely obtain
      • String saveAddress: store document address
      • boolean precedence: real if activity was high priority

Instance:

ReportStructure report = dm.singleDownloadStatus(taskToken);

It’s a record means for returning the list of download job in similar state that developers want.

  • Record<ReportStruct> DownloadManagerPro.downloadTasksInSameState(int state)
    • int state: any download in it’s existence time throughout 6 state.
      • TaskState.INIT: process intruduce for library and gave you token again but it didn’t began but.
      • TaskState.READY: obtain job data fetch from its URL and it’s ready to get started.
      • TaskState.DOWNLOADING: obtain process in downloading procedure.
      • TaskState.PAUSED: obtain job in puase state. If in middle of downloading procedure web disconnected; job is going to puase state and you'll get started it later
      • TaskState.DOWNLOAD_FINISHED: obtain job downloaded utterly but their chunks did not rebuild.
      • TaskState.END: after rebuild download job chunks, activity goes to this state and notified developer with OnDownloadCompleted(lengthy taskToken) interface

Instance:

Listing<ReportStructure> document = dm.downloadTasksInSameState(TaskState.INIT);

this technique returns listing of closing finished Obtain duties in “ReportStructure” style, developers can use it for notifying whether the duty is done or now not.

  • Checklist<ReportStructure> DownloadManagerPro.lastCompletedTasks()
    • go back Checklist<ReportStructure> : listing of finished download from last called unNotifiedCheck() way till now.

Instance:

Listing<ReportStructure> completedDownloadTasks = dm.lastCompletedTasks();

this technique assessments all un notified duties, so in another “lastCompletedDownloads” name ,finished activity doesn't show up again. “lastCompletedDownloads”: Displays the record of latest finished downloads. Calling this method, all of the duties that had been shown in the earlier report, will probably be eradicated from “lastCompletedDownloads”

  • void DownloadManagerPro.unNotifiedCheck()

Example:

dm.unNotifiedCheck()

this technique delete obtain activity

  • boolean DownloadManagerPro.delete(int token, boolean deleteTaskFile)

    • int token: download process token
    • boolean deleteTaskFile: deletes obtain job from database and set deleteTaskFile as true, then it is going to stored folder and delete that record.

    • return boolean : if delete is effectively it returns true otherwise fake

Instance:

dm.delete(12, false);

this technique closes database connection.

  • void DownloadManagerPro.disConnectDB()

Instance:

dm.disConnectDb();

Technical Support

I Hope you enjoy our work. in the event you have any questions, please contact us from our profile web page right here and don’t overlook to turn us your love through score us or leaving a assessment.
FULL DOWNLOAD

No comments:

Post a Comment

Trik tersembunyi Bermain Slither.io agar menjadi no 1 | cara tau ampuh

Slither.io Unblocked Play Engaging in online game playing avails a chance for one to have a great experience. This opens up an enormous amo...