Home / Premium Pro Plugins / Download Manager Android/Java Library

Download Manager Android/Java Library

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...Loading...



DOWNLOAD

This obtain supervisor native extension lets customers obtain huge information as quick as attainable by downloading the information in chunks. on prime of that, the downloads have to be resume-able to ensure that obtain gained’t fail on any situation. Utilizing this android builders can give attention to their app/recreation logic with out worrying about learn how to deal with information information.

Demo

As a way to get a sense of what this obtain supervisor library is all about, we’ve created a take a look at apk Demo so you possibly can set up it in your Android machine and take a look at it for your self.

Options / What you get

  • tremendous straightforward to make use of
  • can be utilized individually in any extension
  • resolve on obtain sections/chunks your self
  • handle queue for downloads
  • categorize downloads with prioritization
  • begin a couple of obtain at a time
  • get experiences in your obtain standing

Technical Specs

This obtain supervisor android/java library which builders can use of their apps and mean you can obtain information in parallel mechanism in some chunks and notify builders about duties standing (any obtain file course of is a process). Every obtain process cross 6 stats in its lifetime.

  1. init
  2. prepared
  3. downloading
  4. paused
  5. obtain completed
  6. finish

Screenshot

Within the first stage, you want to embody these permissions in your AndroidManifest.xml file

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

After that, import com.golshadi.downloadManager package deal in your packages folder.
So now every thing is able to begin.

Let’s get began

One of many essential advantages of this lib is that you simply don’t must initialize object fully earlier than getting any experiences.

DownloadManagerPro dm = new DownloadManagerPro(Context);

to get report about duties you need to use these strategies that can be launched in a while this doc:

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

Consideration: 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 provides him a listener to poke you about duties standing.

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

    • String saveFielPath: folder tackle that you simply need to save your accomplished obtain process in it.
    • int maxChunk : variety of most chunks. any process is split into some chunks and obtain them in parallel. it’s higher to not outline greater than 16 chunks; however when you do it’s set to 16 mechanically.
    • DownloadManagerListener listenerClass on this package deal an interface created to report developer obtain duties standing. this interface consists of some summary strategies that can be launched later.

    Instance:

    public class MyActivity extends Exercise implements DownloadManagerListener 
        ...
        public void methodName() 
            ...
            // you possibly can solely go this for context however right here i need to present clearly
            DownloadManagerPro dm = new DownloadManagerPro(this.getApplicationContext());
            dm.init("downloadManager/", 12, this);
            ...
        
        ...
    
    

there are 3 ways to outline your obtain process, so you possibly can outline it any method you need. for instance When you didn’t set most chunks quantity or sd card folder tackle it makes use of your initialized values. these strategies return you a process id that you could name to begin or pause that process utilizing this token.

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

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

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

    • String saveName: defining te title of desired obtain file.
    • String url : Location of desired downlaod file.
    • int chunk : Variety of chunks which obtain file has been divided into.
    • String sdCardFolder : Location of the place person need to save the file.
    • boolean overwrite : Overwrite if exists one other file with the identical title. If true, overwrite and change the file. If false, discover new title and put it aside with new title.
    • boolean precedence : Grant precedence to extra desired information to be downloaded.

    • return int process id: process token

    Instance:

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

this methodology utilization is to begin a obtain process. If obtain process doesn’t get began since this process is in downloading state, it throw you an IOException. When obtain process begin to obtain this lib notify you with OnDownloadStarted interface

  • void DownloadManagerPro.startDownload(int token) throws IOException

    • int token: It’s an assigned token to every new obtain which is taken into account as obtain process id.

    Instance:

    attempt 
            dm.startDownload(taskToekn);
    
         catch (IOException e) 
            e.printStackTrace();
        
    

pause a obtain duties that you simply point out and when that process paused this lib notify you with OnDownloadPaused interface

  • void DownloadManagerPro.pauseDownload(int token)
    • int token: It’s an assigned token to every new obtain which is taken into account as obtain process id.

Instance:

dm.pauseDownload(taskToekn);

StartQueueDownload methodology create a queue kind on what you need and begin obtain queue duties with downloadTaskPerTime quantity concurrently. If obtain duties are operating in queue and also you attempt to begin it once more it throws a QueueDownloadInProgressException exception.

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

    • int downloadTaskPerTime: the variety of process that may be downloaded concurrently
    • int precedence: Grant precedence to extra desired information to be downloaded.

      • QueueSort.HighPriority : solely excessive precedence
      • QueueSort.LowPriority : solely low precedence
      • QueueSort.HighToLowPriority : kind queue from excessive to low precedence
      • QueueSort.LowToHighPriority : kind queue from low to excessive precedence
      • QueueSort.earlierFirst : kind queue from earlier to oldest duties
      • QueueSort.oldestFirst : kind queue from previous to earlier duties

Instance:

attempt 
        dm.startQueueDownload(three, QueueSort.oldestFirst);

     catch (QueueDownloadInProgressException e) 
        e.printStackTrace();
    

this methodology pauses queue obtain and if no queue obtain was began it throws a QueueDownloadNotStartedException exception.

  • void DownloadManagerPro.pauseQueueDownload()throws QueueDownloadNotStartedException

Instance:

attempt 
        dm.pauseQueueDownload();

     catch (QueueDownloadNotStartedException e)
        e.printStackTrace();
    

Stories

On this part we’re working with experiences since we have to get duties standing and a few helpful details about these standing.

It experiences process obtain data in “ReportStructure” type utilizing a token (obtain process id) and at last returns the statue of that token.

  • ReportStruct DownloadManagerPro.SingleDownloadStatus(int token)

    • int toekn: process token

    • return ReportStructure object and it has a way to transform these information to json

      • int id: process token
      • String title: file title that can be saved in your sdCard
      • int state: obtain state quantity
      • String url: file obtain hyperlink
      • lengthy fileSize: downloaded bytes
      • boolean resumable: obtain hyperlink is resumable or not
      • String sort: file MIME
      • int chunks: process chunks quantity
      • double p.c: downloaded file p.c
      • lengthy downloadLength: measurement that may get out of your sd card after it fully obtain
      • String saveAddress: save file tackle
      • boolean precedence: true if process was excessive precedence

Instance:

ReportStructure report = dm.singleDownloadStatus(taskToken);

It’s a report methodology for returning the checklist of obtain process in identical state that builders need.

  • Listing<ReportStruct> DownloadManagerPro.downloadTasksInSameState(int state)
    • int state: any obtain in it’s life time throughout 6 state.
      • TaskState.INIT: process intruduce for library and gave you token again but it surely didn’t began but.
      • TaskState.READY: obtain process information fetch from its URL and it’s prepared to begin.
      • TaskState.DOWNLOADING: obtain process in downloading course of.
      • TaskState.PAUSED: obtain process in puase state. If in center of downloading course of web disconnected; process goes to puase state and you can begin it later
      • TaskState.DOWNLOAD_FINISHED: obtain process downloaded fully however their chunks didn’t rebuild.
      • TaskState.END: after rebuild obtain process chunks, process goes to this state and notified developer with OnDownloadCompleted(lengthy taskToken) interface

Instance:

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

This methodology returns checklist of final accomplished Obtain duties in “ReportStructure” type, builders can use it for notifying whether or not the duty is accomplished or not.

  • Listing<ReportStructure> DownloadManagerPro.lastCompletedTasks()
    • return Listing<ReportStructure> : checklist of accomplished obtain from final known as unNotifiedCheck() methodology until now.

Instance:

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

This methodology checks all un notified duties, so in one other “lastCompletedDownloads” name ,accomplished process doesn’t present up once more. “lastCompletedDownloads”: Reveals the checklist of newest accomplished downloads. Calling this methodology, all the duties that have been proven within the earlier report, can be eradicated from “lastCompletedDownloads”

  • void DownloadManagerPro.unNotifiedCheck()

Instance:

dm.unNotifiedCheck()

this methodology delete obtain process

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

    • int token: obtain process token
    • boolean deleteTaskFile: deletes obtain process from database and set deleteTaskFile as true, then it goes to saved folder and delete that file.

    • return boolean : if delete is efficiently it returns true in any other case false

Instance:

dm.delete(12, false);

This methodology closes database connection.

  • void DownloadManagerPro.disConnectDB()

Instance:

dm.disConnectDb();

Technical Assist

I hope you take pleasure in our work. When you have any questions, please contact us from our profile web page right here and don’t neglect to point out us your love by ranking us or leaving a overview.

DOWNLOAD

Check Also

top-FlappyDesk.jpg

Fun Game – FlappyDesk – GameCenter – iAd – AdMob – IOS 9

DOWNLOAD If you happen to Like this App, please don’t neglect charge it!This app solely ...

inline_preview_590x300_JPG.jpg

Monkey Business (Unity 5.3.5)

DOWNLOAD Worth lowered throughout winter holidays from $59 to $39, Prolonged License is lowered accordingly ...