Giter Site home page Giter Site logo

huxq17 / pump Goto Github PK

View Code? Open in Web Editor NEW
219.0 6.0 29.0 16.43 MB

A smart tool for android download,support BreakPoint、MultiTask and MultiThread.

Java 95.11% Kotlin 4.89%
android multiple-thread breakpoint-download multitask android-download-manager

pump's Introduction

Pump

Android Arsenal

Pump is a fast, easy-to-use android download library that supports multitask, multithread, and breakpoint download. Use HTTP caching mechanism to avoid unnecessary download and make download smarter. For more information, see the wiki.

See the 中文文档 for Chinese readme.

Download

App module build.gradle:

dependencies {
   implementation'com.huxq17.pump:download:1.3.10'
   implementation 'com.squareup.okhttp3:okhttp:lastversion'
}

Gifs

Single Task Multiple Task

Proguard Rules

-keep class com.huxq17.download.** { *; }
-dontwarn okhttp3.**
-dontwarn okio.**

About me

License

Copyright (C) 2020 huxq17

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License

pump's People

Contributors

huxq17 avatar xiaoqian-hu-20230331 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pump's Issues

null cannot be cast to non-null type

I use your example code

class DownloadsFragment : Fragment() {
	private var downloadObserver: DownloadListener = object : DownloadListener() {
		override fun onProgress(progress: Int) {
			try {
				val viewHolder = downloadInfo.extraData as DownloadViewHolder <--Sometimes getting error at this line
				val tag = map[viewHolder]
				if (tag != null && tag.filePath == downloadInfo.filePath) {
					viewHolder.bindData(downloadInfo, status)
				}
			} catch (e: Exception) {

			}
		}

		override fun onFailed() {
			super.onFailed()
			LogUtil.e("onFailed code=" + downloadInfo.errorCode)
		}
	}

	private lateinit var downloadInfoList: MutableList<out DownloadInfo>
	private var downloadAdapter: DownloadAdapter? = null
	private val map = HashMap<DownloadViewHolder, DownloadInfo>()
	override fun onCreateView(
		inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
	): View? {
		return inflater.inflate(R.layout.fragment_downloads, container, false)
	}

	override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
		downloadInfoList = if (TextUtils.isEmpty(tag)) Pump.getAllDownloadList() else Pump.getDownloadListByTag(tag)
		downloadObserver.enable()
		Collections.sort(downloadInfoList) { o1, o2 -> (o1.createTime - o2.createTime).toInt() }
		rv_downloads.layoutManager = LinearLayoutManager(context)
		downloadAdapter = DownloadAdapter(map, downloadInfoList, context!!)
		rv_downloads.adapter = downloadAdapter
		
	}

}
 webview.setDownloadListener(object: DownloadListener {
            override fun onDownloadStart(
                url: String?,
                userAgent: String?,
                contentDispoition: String?,
                mimeType: String?,
                p4: Long
            ) {

                        val getFileName = URLUtil.guessFileName(url, contentDispoition, mimeType)
                        val file = File(externalCacheDir!!.absolutePath, getFileName)
                        Pump.newRequest(url, file.absolutePath)
                            .forceReDownload(true)
                            .threadNum(3)
                            .setRetry(3, 200)
                            .submit()
                        Toast.makeText(applicationContext, "Download dimulai", Toast.LENGTH_SHORT).show()
                }
        })

Everytime i start downloading files, sometimes the files does not show up on DownloadFragment, and need to re-enable storage permission. I don't know if it is related to storage permission issue, but previously i already set the permission ON

java.util.ConcurrentModificationException

D/Pump: huTest task video133.mp4 is ready,remaining 1 permits.
D/Pump: huTest start run task=video133.mp4
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
java.util.ConcurrentModificationException
at java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:757)
at java.util.LinkedHashMap$LinkedKeyIterator.next(LinkedHashMap.java:780)
at com.huxq17.download.message.MessageCenter$1.handleMessage(MessageCenter.java:35)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6810)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)

file:// and content:// uri app only give file:// scheme

Hi i have added a button into the list of downloads and when i am using android 9 or above i cannot open the file in a file manager because the library is only returning the old file:// schematic but the new android 9 and above require the content:// scheme..

any help would be apreciated

Please noet the list is downloaded video files..

RequestBuilder value reset when App restarts

Some download URL need custom Header value to download file. I can set those headers using setRequestBuilder(pumpReq) in Pump.newRequest() method.

This will allow the file to download properly. But If I pause a download and then force stop app and again try to resume download it will fail with error "ERROR_UNKNOWN_SERVER_ERROR".

Is there any way to fix this?

How to restrict the space used by cache?

First of all, kudos to you and thanks for creating such library. It is very helpful.

How to restrict the space used by cache? For eg. - after 100MB is reached, the old files should automatically get deleted to make space for new files, restricting the space used by cache to 100MB.

Crash when download start after update to 1.3.4 and later

E/AndroidRuntime: FATAL EXCEPTION: pool-22-thread-3
    java.lang.NullPointerException: Attempt to invoke interface method 'void okio.BufferedSink.flush()' on a null object reference
        at com.huxq17.download.core.connection.OkHttpDownloadConnection.flushDownload(OkHttpDownloadConnection.java:71)
        at com.huxq17.download.core.task.DownloadBlockTask.execute(DownloadBlockTask.java:102)
        at com.huxq17.download.core.task.Task.run(Task.java:23)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)

last version issue

i am using implementation'com.huxq17.pump:download:1.2.11' version but import com.huxq17.download.DownloadInfo; not imported in app

Download failed but listener doesn't notify

Can you fix the listener? Download task may be killed by another service but DownloadListener doesn't notify and keep getting stuck at onProgress.

image

private var downloadListener: DownloadListener = object: DownloadListener() {
    override fun onProgress(progress: Int) {
       NotificationCompat
       ...
    }
     override fun onFailed() {  <-- status should be here
       NotificationCompat
       ...
    }

}

Error when attempting to download a file

Using the wonderful library in app, but I consistently get the below error whenever I add something to be downloaded:

 java.net.ProtocolException: Unexpected status line: ID3��������`.COMM�������������eng��https://musicrider.org/��TXXX�������������Upload��Hunter��TIT2��������������T��r��u��t��h�� ��H��u��r��t��s��TPE2�������������L��i��z��z��o��TPE1�������������L��i��z��z��o��TALB������%�������U��.��K�� ��S��i��n��g��l��e�� ��C��h��a��r��t��s��TYER��������������2��0��1��7��TCON��������������(��1��3��)��P��o��p��WXXX���������������https://musicrider.org/APIC���/�������image/jpg���37���������JFIF������,�,��������C��������������
2019-10-19 13:08:12.183 12013-14652/com.kokonetworks.kokonet.client W/System.err:     at okhttp3.internal.http.StatusLine$Companion.parse(StatusLine.kt:78)
2019-10-19 13:08:12.185 12013-14652/com.kokonetworks.kokonet.client W/System.err:     at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:181)
2019-10-19 13:08:12.185 12013-14652/com.kokonetworks.kokonet.client W/System.err:     at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:105)
2019-10-19 13:08:12.185 12013-14652/com.kokonetworks.kokonet.client W/System.err:     at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:82)
2019-10-19 13:08:12.185 12013-14652/com.kokonetworks.kokonet.client W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
2019-10-19 13:08:12.186 12013-14652/com.kokonetworks.kokonet.client W/System.err:     at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:37)
2019-10-19 13:08:12.186 12013-14652/com.kokonetworks.kokonet.client W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)

I am using the below code for downloading:

Pump.newRequest(fileRemotePath, fileDownloadPath.absolutePath)
            .threadNum(1)
            .forceReDownload(false)
            .setRetry(3, 200)
            .listener(object : DownloadListener() {

                override fun onProgress(progress: Int) {

                }

                override fun onSuccess() {
                    Toast.makeText(KOKONetApp.INSTANCE.applicationContext, "Download Finished", Toast.LENGTH_SHORT)
                        .show()
                }

                override fun onFailed() {
                    Toast.makeText(KOKONetApp.INSTANCE.applicationContext, "Download failed", Toast.LENGTH_SHORT)
                        .show()
                }
            })
            .submit()

what could be the issue?

how to auto resume download and show custom notification?

I have found this library newly. It's really perfect but I have just two problems:

  1. when I go out of the download activity and come back, the download progress is paused and I have to start it again manually; How I can start it programmatically not manually when I come back to the activity?
  2. How I can show custom notification in the notification bar showing the current download progress and It's other info?

Crash: Attempt to invoke interface method on a null object reference

Hi, Pump crashes by calling build() method from new config

in my Application class:

private DownloadListener downloadObserver = new DownloadListener() {
/**/
}

private void initPumpDownloader() {
        Pump.newConfigBuilder()
                .setMaxRunningTaskNum(1)
                .setMinUsableStorageSpace(4 * 1024L)
                .setDownloadConnectionFactory(new OkHttpDownloadConnection.Factory(OKHttpUtil.get()))
                .build();

        downloadObserver.enable();
    }

crash:

Unable to create application com.myapp.App: java.lang.NullPointerException: Attempt to invoke interface method 'void com.huxq17.download.core.service.IDownloadConfigService.setConfig(com.huxq17.download.config.DownloadConfig)' on a null object reference
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6759)
        at android.app.ActivityThread.access$1400(ActivityThread.java:244)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1952)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7700)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:997)
     Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void com.huxq17.download.core.service.IDownloadConfigService.setConfig(com.huxq17.download.config.DownloadConfig)' on a null object reference
        at com.huxq17.download.config.DownloadConfig$Builder.build(DownloadConfig.java:90)
        at com.myapp.App.initPumpDownloader(App.java:126)
        at com.myapp.App.onCreate(App.java:87)
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6754)

Pump Pause not working

Hello, once again thanks for this awesome library. I have however discovered that the method

Pump.pause(id) doesn't work. The download keeps on continuing with progress updates, here is how I initialized it

 boolean isPaused = AppPrefs.isPaused(episode.getEpisodeId());
              String downloadId = generateDownloadIdFromEpisode(episode)
          if (isPaused) {
              Pump.resume(downloadId);
          } else {;
              Pump.newRequest(downloadUrl, filePath)
                      .setId(downloadId)
                      .setDownloadTaskExecutor(ApplicationLoader.getVideoDownloadDispatcher())
                      .forceReDownload(false)
                      .submit();
              AppPrefs.mapEpisodeIdToDownloadId(episode.getEpisodeId(), episode.getEpisodeId().hashCode());
          }

     //Here is the pause function

  public static void pauseDownload(Episode episode) {
      String downloadKeyFromEpisode = getDownloadIdFromEpisode(episode);
      Pump.pause(downloadKeyFromEpisode); //This never works, however Pump.stop(downloadKeyFromEpisode ) works well all the time.
      AppPrefs.setPaused(episode.getEpisodeId(), true);
  }

Any pointers on getting pause to work would be greatly appreciated.

Thanks.

Issue with downloader

having issue in downloading on android 10 version.
Doesnot download any file.

Screenshot_20200814-003244_Downloadtest1

Please tell some thing about this ###

  • [ ]

issue

Too many follow-up requests: 21

Is there any fix with this kind of error? I saw many answers on SO had an issue with API or too many redirections.
Can you test download file from dood.to?

Thank you

W/System.err: java.net.ProtocolException: Too many follow-up requests: 21
W/System.err:     at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:121)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
        at com.androidnetworking.interceptors.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:154)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
        at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:197)
        at okhttp3.internal.connection.RealCall.execute(RealCall.kt:148)
W/System.err:     at com.huxq17.download.core.connection.OkHttpDownloadConnection.connect(OkHttpDownloadConnection.java:51)
        at com.huxq17.download.core.interceptor.CheckCacheInterceptor.intercept(CheckCacheInterceptor.java:56)
        at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:43)
        at com.huxq17.download.core.interceptor.RetryInterceptor.intercept(RetryInterceptor.java:26)
        at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:43)
        at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:31)```

UNIQUE constraint failed: download_info_temp.id (Sqlite code 1555 SQLITE_CONSTRAINT_PRIMARYKEY)

Hi, new error at 1.3.9

Fatal Exception: android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: download_info_temp.id (Sqlite code 1555 SQLITE_CONSTRAINT_PRIMARYKEY), (OS error - 2:No such file or directory)
at android.database.sqlite.SQLiteConnection.nativeExecuteForChangedRowCount(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.executeForChangedRowCount(SQLiteConnection.java:877)
at android.database.sqlite.SQLiteSession.executeForChangedRowCount(SQLiteSession.java:776)
at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:66)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1899)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1816)
at com.huxq17.download.db.DBOpenHelper.newVersion4(DBOpenHelper.java:72)
at com.huxq17.download.db.DBOpenHelper.newVersion5(DBOpenHelper.java:92)
at com.huxq17.download.db.DBOpenHelper.onUpgrade(DBOpenHelper.java:135)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:436)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:332)
at com.huxq17.download.db.DBService.getDatabase(DBService.java:132)
at com.huxq17.download.db.DBService.getDownloadInfo(DBService.java:112)
at com.huxq17.download.core.DownloadDispatcher.createDownloadInfo(DownloadDispatcher.java:202)
at com.huxq17.download.core.DownloadDispatcher.createTaskFromRequest(DownloadDispatcher.java:162)
at com.huxq17.download.core.DownloadDispatcher.consumeRequest(DownloadDispatcher.java:73)
at com.huxq17.download.core.DownloadDispatcher.execute(DownloadDispatcher.java:94)
at com.huxq17.download.core.task.Task.run(Task.java:23)
at java.util.concurrent.ThreadPoolExecutor.processTask(ThreadPoolExecutor.java:1187)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:929)

Download Completed/Total Size Error

Hello, of recent I noticed a bug where the completed size of the download is weirdly greater than the total size as returned from the onProgress function as below

public static DownloadListener globalDownloadListener = new DownloadListener() {

       @Override
       public void onProgress(int progress) {
           int progressPercent = downloadInfo.getProgress();
           long completedSize = downloadInfo.getCompletedSize();
           long totalSize = downloadInfo.getContentLength();

          //The totalSize is 72.5MB but the completedSize is going beyond that and downloads 
          //infinitely...like **73MB/72.5MB**.........**75MB/72.5MB**

          //This is so weird, it's wasting my users data,please help.

         //I had to force stop the download with the below code
         if (completedSize > totalSize) {
               Pump.pause(downloadInfo.getId());
               Pump.stop(downloadInfo.getId());
               Pump.deleteById(downloadInfo.getId());
           }
       }

       @Override
       public void onFailed() {
           handleDownloadError(getDownloadInfo());
       }

       @Override
       public void onSuccess() {
           handleCompletedDownload(getDownloadInfo());
       }

   };

Pump.stop not working reliably

Hello, the Pump.stop() function to cancel a download doesn't work reliably. Even after calling the function the download still continues and the onProgress still fires. See below

 public static void cancelDownload(String downloadId) {
       Pump.pause(downloadId);
       Pump.stop(downloadId);
      //Download was cancelled but the onProgress(int progress) is still firing the progress of the
     //download
   }

Any help would be greatly appreciated.

downloading file is stopped, recyclerview freeze when DownloadListActivity is called

My AndroidManifest:

<activity android:name="com.example.app.DownloadListActivity" />

This is my code because I want to see the file/s that are/is downloading immediately after I start the download:

//start the download
String url = "https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_480_1_5MG.mp4";
Pump.newRequest(url, Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath() + "/Test Downloads")
                .setId(url)
                .setDownloadTaskExecutor(ApplicationClass.getInstance().musicDownloadDispatcher)
                .forceReDownload(true)
                .submit();

//I call this activity immediately because I want to see the progress automatically without having to click the "view download list" button
DownloadListActivity.start(requireActivity(), "");

The problem is that, yes the download list activity is shown but doesn't move or I cant click the pause button or do anything. Also, the download freezes and wont save (i tried to just wait even if the mb progress doesnt move but still the file isnt save, p.s its only 1.5mb and i have a fast wifi)

The only thing that makes the download works is if I don't open the DownloadListActivity at all. I tried to delay to open the DownloadListActivity like below:

Pump.newRequest(url, Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath() + "/Test Downloads")
                .setId(url)
                .setDownloadTaskExecutor(ApplicationClass.getInstance().musicDownloadDispatcher)
                .forceReDownload(true)
                .submit();
        
        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                DownloadListActivity.start(requireActivity(), "");
            }
        }, 5000);

and boom, the download saves/works (file is only 1.5mb so in the 5 seconds of delay time, the download is already finished)... the problem with this is ofcourse the progress can't be seen live + random videos and file sizes are being downloaded once my app is live, my users are not clairvoyant people so ofcourse its impractical to guess whether to open the DownloadListActivity just because the download is already finished, what's the purpose of view download list with progress shown after all right?

In conclusion, the problem here is the DownloadListActivity. I don't know what's going on, all codes I used is from the default code you've given.

Anyone who can give me an idea of what's going on is very helpful. Thank you in advance!

E/SQLiteLog: (1) table download_info has no column named schema_uri

hello , i have this error whyle trying to download url=http://wdj.anzhi.com/dl_app.php?s=2397021&channel=wandoujia.
i have such exception. On android 9 same code works without this exception.

2021-04-12 16:27:36.825 14323-14323/com.example.app V/AsyncHttpRH: Progress 9953 from 1 (995300%)
2021-04-12 16:27:38.329 14323-14669/com.example.app E/SQLiteLog: (1) table download_info has no column named schema_uri in "INSERT OR REPLACE INTO download_info(thread_num,finished,create_time,schema_uri,id,tag,url,path,file_length) VALUES (?,?,?,?,?,?,?,?,?)"
2021-04-12 16:27:38.329 14323-14669/com.example.app E/SQLiteDatabase: Error inserting thread_num=0 finished=0 create_time=1618234058325 schema_uri=null id=http://wdj.anzhi.com/dl_app.php?s=2397021&channel=wandoujia tag=music url=http://wdj.anzhi.com/dl_app.php?s=2397021&channel=wandoujia path=null file_length=-1
android.database.sqlite.SQLiteException: table download_info has no column named schema_uri (code 1 SQLITE_ERROR): , while compiling: INSERT OR REPLACE INTO download_info(thread_num,finished,create_time,schema_uri,id,tag,url,path,file_length) VALUES (?,?,?,?,?,?,?,?,?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1045)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:652)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:590)
at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:61)
at android.database.sqlite.SQLiteStatement.(SQLiteStatement.java:33)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1699)
at android.database.sqlite.SQLiteDatabase.replace(SQLiteDatabase.java:1617)
at com.huxq17.download.db.DBService.updateInfo(DBService.java:78)
at com.huxq17.download.core.DownloadDispatcher.createDownloadInfo(DownloadDispatcher.java:185)
at com.huxq17.download.core.DownloadDispatcher.createTaskFromRequest(DownloadDispatcher.java:150)
at com.huxq17.download.core.DownloadDispatcher.consumeRequest(DownloadDispatcher.java:65)
at com.huxq17.download.core.DownloadDispatcher.run(DownloadDispatcher.java:86)
2021-04-12 16:27:38.330 14323-14669/com.example.app D/Pump: Pump Task http://wdj.anzhi.com/dl_app.php?s=2397021&channel=wandoujia is ready.
2021-04-12 16:27:38.332 14323-15612/com.example.app D/Pump: Pump start run http://wdj.anzhi.com/dl_app.php?s=2397021&channel=wandoujia at thread name=MusicDownloadDispatcher-thread-4
2021-04-12 16:27:38.338 561-2074/? I/system_server: oneway function results will be dropped but finished with status OK and parcel size 4
2021-04-12 16:27:38.472 561-2074/? I/system_server: oneway function results will be dropped but finished with status OK and parcel size 4
2021-04-12 16:27:39.561 14323-15612/com.example.app E/SQLiteLog: (1) table download_info has no column named schema_uri in "INSERT OR REPLACE INTO download_info(thread_num,finished,create_time,schema_uri,id,tag,url,path,file_length) VALUES (?,?,?,?,?,?,?,?,?)"
2021-04-12 16:27:39.562 14323-15612/com.example.app E/SQLiteDatabase: Error inserting thread_num=0 finished=0 create_time=1618234058325 schema_uri=null id=http://wdj.anzhi.com/dl_app.php?s=2397021&channel=wandoujia tag=music url=http://wdj.anzhi.com/dl_app.php?s=2397021&channel=wandoujia path=/storage/emulated/0/Android/data/com.example.app/files/pump_cache/com.zhiyoo_43951200_0.apk file_length=-1
android.database.sqlite.SQLiteException: table download_info has no column named schema_uri (code 1 SQLITE_ERROR): , while compiling: INSERT OR REPLACE INTO download_info(thread_num,finished,create_time,schema_uri,id,tag,url,path,file_length) VALUES (?,?,?,?,?,?,?,?,?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1045)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:652)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:590)
at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:61)
at android.database.sqlite.SQLiteStatement.(SQLiteStatement.java:33)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1699)
at android.database.sqlite.SQLiteDatabase.replace(SQLiteDatabase.java:1617)
at com.huxq17.download.db.DBService.updateInfo(DBService.java:78)
at com.huxq17.download.core.task.DownloadTask.updateInfo(DownloadTask.java:167)
at com.huxq17.download.core.interceptor.ConnectInterceptor.prepareDownloadFile(ConnectInterceptor.java:301)
at com.huxq17.download.core.interceptor.ConnectInterceptor.intercept(ConnectInterceptor.java:83)
at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:43)
at com.huxq17.download.core.interceptor.RetryInterceptor.intercept(RetryInterceptor.java:26)
at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:43)
at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:31)
at com.huxq17.download.core.task.DownloadTask.downloadWithDownloadChain(DownloadTask.java:98)
at com.huxq17.download.core.task.DownloadTask.execute(DownloadTask.java:84)
at com.huxq17.download.core.task.Task.run(Task.java:23)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
2021-04-12 16:27:39.579 14323-15612/com.example.app E/SQLiteLog: (1) table download_info has no column named schema_uri in "INSERT OR REPLACE INTO download_info(thread_num,finished,create_time,schema_uri,id,tag,url,path,file_length) VALUES (?,?,?,?,?,?,?,?,?)"
2021-04-12 16:27:39.579 14323-15612/com.example.app E/SQLiteDatabase: Error inserting thread_num=2 finished=0 create_time=1618234058325 schema_uri=null id=http://wdj.anzhi.com/dl_app.php?s=2397021&channel=wandoujia tag=music url=http://wdj.anzhi.com/dl_app.php?s=2397021&channel=wandoujia path=/storage/emulated/0/Android/data/com.example.app/files/pump_cache/com.zhiyoo_43951200_0.apk file_length=2957323
android.database.sqlite.SQLiteException: table download_info has no column named schema_uri (code 1 SQLITE_ERROR): , while compiling: INSERT OR REPLACE INTO download_info(thread_num,finished,create_time,schema_uri,id,tag,url,path,file_length) VALUES (?,?,?,?,?,?,?,?,?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1045)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:652)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:590)
at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:61)
at android.database.sqlite.SQLiteStatement.(SQLiteStatement.java:33)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1699)
at android.database.sqlite.SQLiteDatabase.replace(SQLiteDatabase.java:1617)
at com.huxq17.download.db.DBService.updateInfo(DBService.java:78)
at com.huxq17.download.core.task.DownloadTask.updateInfo(DownloadTask.java:167)
at com.huxq17.download.core.interceptor.ConnectInterceptor.checkDownloadFile(ConnectInterceptor.java:199)
at com.huxq17.download.core.interceptor.ConnectInterceptor.intercept(ConnectInterceptor.java:137)
at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:43)
at com.huxq17.download.core.interceptor.RetryInterceptor.intercept(RetryInterceptor.java:26)
at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:43)
at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:31)
at com.huxq17.download.core.task.DownloadTask.downloadWithDownloadChain(DownloadTask.java:98)
at com.huxq17.download.core.task.DownloadTask.execute(DownloadTask.java:84)
at com.huxq17.download.core.task.Task.run(Task.java:23)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
2021-04-12 16:27:40.505 1287-1401/? I/PeriodicStatsRunner: PeriodicStatsRunner.call():180 call()
2021-04-12 16:27:40.505 1287-1401/? I/PeriodicStatsRunner: PeriodicStatsRunner.call():184 No submit PeriodicStats since input started.
2021-04-12 16:27:41.428 561-2074/? I/system_server: oneway function results will be dropped but finished with status OK and parcel size 4
2021-04-12 16:27:41.576 14323-15567/com.example.app V/FA: Inactivity, disconnecting from the service
2021-04-12 16:27:41.703 1287-1401/? I/PeriodicStatsRunner: PeriodicStatsRunner.call():180 call()
2021-04-12 16:27:41.704 1287-1401/? I/PeriodicStatsRunner: PeriodicStatsRunner.call():184 No submit PeriodicStats since input started.
2021-04-12 16:27:42.375 14323-15612/com.example.app D/Pump: Pump Merge com.zhiyoo_43951200_0.apk spend=11; file.length=2957323
2021-04-12 16:27:42.379 14323-15612/com.example.app E/SQLiteLog: (1) table download_info has no column named schema_uri in "INSERT OR REPLACE INTO download_info(thread_num,finished,create_time,schema_uri,id,tag,url,path,file_length) VALUES (?,?,?,?,?,?,?,?,?)"
2021-04-12 16:27:42.379 14323-15612/com.example.app E/SQLiteDatabase: Error inserting thread_num=2 finished=1 create_time=1618234058325 schema_uri=null id=http://wdj.anzhi.com/dl_app.php?s=2397021&channel=wandoujia tag=music url=http://wdj.anzhi.com/dl_app.php?s=2397021&channel=wandoujia path=/storage/emulated/0/Android/data/com.example.app/files/pump_cache/com.zhiyoo_43951200_0.apk file_length=2957323
android.database.sqlite.SQLiteException: table download_info has no column named schema_uri (code 1 SQLITE_ERROR): , while compiling: INSERT OR REPLACE INTO download_info(thread_num,finished,create_time,schema_uri,id,tag,url,path,file_length) VALUES (?,?,?,?,?,?,?,?,?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1045)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:652)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:590)
at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:61)
at android.database.sqlite.SQLiteStatement.(SQLiteStatement.java:33)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1699)
at android.database.sqlite.SQLiteDatabase.replace(SQLiteDatabase.java:1617)
at com.huxq17.download.db.DBService.updateInfo(DBService.java:78)
at com.huxq17.download.core.task.DownloadTask.updateInfo(DownloadTask.java:167)
at com.huxq17.download.core.task.DownloadTask.downloadWithDownloadChain(DownloadTask.java:104)
at com.huxq17.download.core.task.DownloadTask.execute(DownloadTask.java:84)
at com.huxq17.download.core.task.Task.run(Task.java:23)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
2021-04-12 16:27:42.380 14323-15612/com.example.app D/Pump: Pump download com.zhiyoo_43951200_0.apk is stopped,and spend=4048

Add More Callbacks to DownloadListener

Thanks so much for this library. I was using Fetch but it has alot of bugs, I just bumped into this library few mins ago. Can you add more callbacks into the DownloadListener like onResumed,onPaused,onStarted,onCancelled like below

private static DownloadListener downloadListener = new DownloadListener() {

        @Override
        public void onProgress(int progress) {
            DownloadInfo downloadInfo = getDownloadInfo();
            handleDownloadProgress(downloadInfo);
        }

        @Override
        public void onFailed() {
            DownloadInfo downloadInfo = getDownloadInfo();
            DownloadInfo.Status downloadStatus = downloadInfo.getStatus();

           //Like, I am confused here how would I know if the fail was as a result of failed or paused

            if (downloadStatus == DownloadInfo.Status.PAUSED) {
                handlePausedDownload(downloadInfo);
            } else if (downloadStatus == DownloadInfo.Status.FAILED) {
                handleDownloadError(downloadInfo);
            }
        }

        @Override
        public void onSuccess() {
            DownloadInfo downloadInfo = getDownloadInfo();
            handleCompletedDownload(downloadInfo);
        }

      //Please add the following
       @Override
        public void onResumed(){
     
         }
 
       @Override
       public void onPaused(){
       }
 
       @Override
       public void onCancelled(){
       }
  
  };

By the way how can I cancel a download and also how do I know if a download was paused. Very important. Thanks.

DownloadTask.getLock()' on a null object reference

Hi, what could be the reason for this error?

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object com.huxq17.download.core.task.DownloadTask.getLock()' on a null object reference
at com.huxq17.download.core.interceptor.MergeFileInterceptor.intercept(MergeFileInterceptor.java:26)
at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:43)
at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:31)
at com.huxq17.download.core.interceptor.ConnectInterceptor.intercept(ConnectInterceptor.java:153)
at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:43)
at com.huxq17.download.core.interceptor.RetryInterceptor.intercept(RetryInterceptor.java:26)
at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:43)
at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:31)
at com.huxq17.download.core.task.DownloadTask.downloadWithDownloadChain(DownloadTask.java:99)
at com.huxq17.download.core.task.DownloadTask.execute(DownloadTask.java:85)
at com.huxq17.download.core.task.Task.run(Task.java:23)
at java.util.concurrent.ThreadPoolExecutor.processTask(ThreadPoolExecutor.java:1187)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:929)

Https url issue

I am unable to download an apk from https link, plz help me.

Can't start the download list activity

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.usamin., PID: 24650
    java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.usamin./com.usamin..activity.drawer.DownloadsActivity2}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.Application.registerActivityLifecycleCallbacks(android.app.Application$ActivityLifecycleCallbacks)' on a null object reference
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3194)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.Application.registerActivityLifecycleCallbacks(android.app.Application$ActivityLifecycleCallbacks)' on a null object reference
        at com.huxq17.download.android.ViewLifecycleHandler$ViewHandlerManager.handleLifecycleForActivity(ViewLifecycleHandler.java:37)
        at com.huxq17.download.android.ViewLifecycleHandler$ViewHandlerManager.access$100(ViewLifecycleHandler.java:25)
        at com.huxq17.download.android.ViewLifecycleHandler.handleLifecycleForActivity(ViewLifecycleHandler.java:18)
        at com.huxq17.download.core.DownloadListener.<init>(DownloadListener.java:19)
        at com.usamin..activity.drawer.DownloadsActivity2$downloadListener$1.<init>(DownloadsActivity2.kt:26)
        at com.usamin..activity.drawer.DownloadsActivity2.<init>(DownloadsActivity2.kt:26)
        at java.lang.Class.newInstance(Native Method)
        at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
        at androidx.core.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:45)
        at android.app.Instrumentation.newActivity(Instrumentation.java:1243)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3182)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016) 
        at android.os.Handler.dispatchMessage(Handler.java:107) 
        at android.os.Looper.loop(Looper.java:214) 
        at android.app.ActivityThread.main(ActivityThread.java:7356) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

Download Listener when app is killed

I want to perform some actions like updating the database and show a custom notification when downloaded is completed even app is killed.

  1. Will download continue after app killed by swiping?
  2. If yes, then will the listener would awake to perform an action even app status is killed?

I tried to do this with the Android DownloadManger class but the listener won't awake once app gets killed.

getDownloadInfo()' on a null object reference

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'com.huxq17.download.core.DownloadDetailsInfo com.huxq17.download.core.task.DownloadTask.getDownloadInfo()' on a null object reference
at com.huxq17.download.utils.Util.setFilePathIfNeed(Util.java:253)
at com.huxq17.download.core.interceptor.ConnectInterceptor.intercept(ConnectInterceptor.java:80)
at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:43)
at com.huxq17.download.core.interceptor.RetryInterceptor.intercept(RetryInterceptor.java:26)
at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:43)
at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:31)
at com.huxq17.download.core.task.DownloadTask.downloadWithDownloadChain(DownloadTask.java:99)
at com.huxq17.download.core.task.DownloadTask.execute(DownloadTask.java:85)
at com.huxq17.download.core.task.Task.run(Task.java:23)
at java.util.concurrent.ThreadPoolExecutor.processTask(ThreadPoolExecutor.java:1187)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:929)

SQLiteException: table download_info_temp has 8 columns but 7 values were

Hello, what could be the reason for this error?

Fatal Exception: android.database.sqlite.SQLiteException: table download_info_temp has 8 columns but 7 values were supplied (code 1 SQLITE_ERROR[1]): , while compiling: INSERT INTO download_info_temp SELECT * FROM download_info;
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1372)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:811)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:590)
at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:62)
at android.database.sqlite.SQLiteStatement.(SQLiteStatement.java:33)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:2321)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:2249)
at com.huxq17.download.db.DBOpenHelper.newVersion4(DBOpenHelper.java:69)
at com.huxq17.download.db.DBOpenHelper.newVersion5(DBOpenHelper.java:89)
at com.huxq17.download.db.DBOpenHelper.onUpgrade(DBOpenHelper.java:132)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:493)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:391)
at com.huxq17.download.db.DBService.getDatabase(DBService.java:132)
at com.huxq17.download.db.DBService.getDownloadInfo(DBService.java:112)
at com.huxq17.download.core.DownloadDispatcher.createDownloadInfo(DownloadDispatcher.java:201)
at com.huxq17.download.core.DownloadDispatcher.createTaskFromRequest(DownloadDispatcher.java:161)
at com.huxq17.download.core.DownloadDispatcher.consumeRequest(DownloadDispatcher.java:72)
at com.huxq17.download.core.DownloadDispatcher.execute(DownloadDispatcher.java:93)
at com.huxq17.download.core.task.Task.run(Task.java:23)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)

Queue Download Requests

How best can I queue requests, one after another. I have a media application and I need the user to be able to download any no. of items on the fly like Netflix download Button. User should be able to resume the download, even if he exited the app,.

Download stuck

I noticed some of other users sometimes getting stuck while downloading, this happened also with me any time.
When it getting stuck Pump.stop() not functioning, and need to wait for a while, maybe when setRetry task done

https://gofile.io/d/M0bg1X

from me
image

other user
image

W/System.err: java.net.SocketTimeoutException: Read timed out
W/System.err:     at com.android.org.conscrypt.NativeCrypto.SSL_read(Native Method)
        at com.android.org.conscrypt.NativeSsl.read(NativeSsl.java:411)
        at com.android.org.conscrypt.ConscryptFileDescriptorSocket$SSLInputStream.read(ConscryptFileDescriptorSocket.java:549)
W/System.err:     at okio.InputStreamSource.read(JvmOkio.kt:90)
        at okio.AsyncTimeout$source$1.read(AsyncTimeout.kt:129)
        at okio.RealBufferedSource.indexOf(RealBufferedSource.kt:449)
        at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.kt:333)
        at okhttp3.internal.http1.HeadersReader.readLine(HeadersReader.kt:29)
        at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:178)
        at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:106)
        at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:79)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34)
W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
        at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
        at com.huxq17.download.core.connection.OkHttpDownloadConnection.connect(OkHttpDownloadConnection.java:44)
        at com.huxq17.download.core.interceptor.ConnectInterceptor.connect(ConnectInterceptor.java:243)
        at com.huxq17.download.core.interceptor.ConnectInterceptor.intercept(ConnectInterceptor.java:72)
W/System.err:     at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:43)
        at com.huxq17.download.core.interceptor.RetryInterceptor.intercept(RetryInterceptor.java:26)
        at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:43)
W/System.err:     at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:31)
        at com.huxq17.download.core.task.DownloadTask.downloadWithDownloadChain(DownloadTask.java:99)
        at com.huxq17.download.core.task.DownloadTask.execute(DownloadTask.java:85)
        at com.huxq17.download.core.task.Task.run(Task.java:23)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)
V/FA: Inactivity, disconnecting from the service
W/System.err: java.net.SocketTimeoutException: timeout
W/System.err:     at okio.SocketAsyncTimeout.newTimeoutException(JvmOkio.kt:143)
        at okio.AsyncTimeout.access$newTimeoutException(AsyncTimeout.kt:162)
        at okio.AsyncTimeout$source$1.read(AsyncTimeout.kt:340)
W/System.err:     at okio.RealBufferedSource.read(RealBufferedSource.kt:188)
        at okhttp3.internal.http1.Http1ExchangeCodec$AbstractSource.read(Http1ExchangeCodec.kt:331)
        at okhttp3.internal.http1.Http1ExchangeCodec$FixedLengthSource.read(Http1ExchangeCodec.kt:368)
        at okhttp3.internal.connection.Exchange$ResponseBodySource.read(Exchange.kt:276)
        at okio.RealBufferedSource.read(RealBufferedSource.kt:267)
        at com.huxq17.download.core.connection.OkHttpDownloadConnection.downloadBuffer(OkHttpDownloadConnection.java:62)
W/System.err:     at com.huxq17.download.core.task.DownloadBlockTask.download(DownloadBlockTask.java:138)
        at com.huxq17.download.core.task.DownloadBlockTask.execute(DownloadBlockTask.java:99)
        at com.huxq17.download.core.task.Task.run(Task.java:23)
        at com.huxq17.download.core.interceptor.ConnectInterceptor.intercept(ConnectInterceptor.java:148)
        at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:43)
        at com.huxq17.download.core.interceptor.RetryInterceptor.intercept(RetryInterceptor.java:26)
W/System.err:     at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:43)
        at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:31)
        at com.huxq17.download.core.task.DownloadTask.downloadWithDownloadChain(DownloadTask.java:99)
        at com.huxq17.download.core.task.DownloadTask.execute(DownloadTask.java:85)
        at com.huxq17.download.core.task.Task.run(Task.java:23)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)
    Caused by: java.net.SocketException: socket is closed
W/System.err:     at com.android.org.conscrypt.ConscryptFileDescriptorSocket$SSLInputStream.read(ConscryptFileDescriptorSocket.java:554)
        at okio.InputStreamSource.read(JvmOkio.kt:90)
        at okio.AsyncTimeout$source$1.read(AsyncTimeout.kt:129)
    	... 20 more
W/System.err: java.net.SocketTimeoutException: timeout
W/System.err:     at okio.SocketAsyncTimeout.newTimeoutException(JvmOkio.kt:143)
W/System.err:     at okio.AsyncTimeout.access$newTimeoutException(AsyncTimeout.kt:162)
        at okio.AsyncTimeout$source$1.read(AsyncTimeout.kt:340)
        at okio.RealBufferedSource.indexOf(RealBufferedSource.kt:449)
W/System.err:     at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.kt:333)
        at okhttp3.internal.http1.HeadersReader.readLine(HeadersReader.kt:29)
        at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:178)
W/System.err:     at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:106)
        at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:79)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34)
W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
W/System.err:     at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
        at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
        at com.huxq17.download.core.connection.OkHttpDownloadConnection.connect(OkHttpDownloadConnection.java:44)
W/System.err:     at com.huxq17.download.core.interceptor.ConnectInterceptor.connect(ConnectInterceptor.java:243)
        at com.huxq17.download.core.interceptor.ConnectInterceptor.intercept(ConnectInterceptor.java:72)
        at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:43)
W/System.err:     at com.huxq17.download.core.interceptor.RetryInterceptor.intercept(RetryInterceptor.java:26)
        at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:43)
        at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:31)
        at com.huxq17.download.core.task.DownloadTask.downloadWithDownloadChain(DownloadTask.java:99)
W/System.err:     at com.huxq17.download.core.task.DownloadTask.execute(DownloadTask.java:85)
W/System.err:     at com.huxq17.download.core.task.Task.run(Task.java:23)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/System.err:     at java.lang.Thread.run(Thread.java:919)
W/System.err: Caused by: java.net.SocketException: socket is closed
        at com.android.org.conscrypt.ConscryptFileDescriptorSocket$SSLInputStream.read(ConscryptFileDescriptorSocket.java:554)
        at okio.InputStreamSource.read(JvmOkio.kt:90)
W/System.err:     at okio.AsyncTimeout$source$1.read(AsyncTimeout.kt:129)
    	... 30 more
W/System.err: java.net.SocketTimeoutException: timeout
W/System.err:     at okio.SocketAsyncTimeout.newTimeoutException(JvmOkio.kt:143)
        at okio.AsyncTimeout.access$newTimeoutException(AsyncTimeout.kt:162)
W/System.err:     at okio.AsyncTimeout$source$1.read(AsyncTimeout.kt:340)
        at okio.RealBufferedSource.indexOf(RealBufferedSource.kt:449)
        at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.kt:333)
        at okhttp3.internal.http1.HeadersReader.readLine(HeadersReader.kt:29)
W/System.err:     at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:178)
        at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:106)
W/System.err:     at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:79)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
W/System.err:     at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
W/System.err:     at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
W/System.err:     at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
        at com.huxq17.download.core.connection.OkHttpDownloadConnection.connect(OkHttpDownloadConnection.java:44)
        at com.huxq17.download.core.interceptor.ConnectInterceptor.connect(ConnectInterceptor.java:243)
W/System.err:     at com.huxq17.download.core.interceptor.ConnectInterceptor.intercept(ConnectInterceptor.java:72)
        at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:43)
        at com.huxq17.download.core.interceptor.RetryInterceptor.intercept(RetryInterceptor.java:26)
        at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:43)
W/System.err:     at com.huxq17.download.core.RealDownloadChain.proceed(RealDownloadChain.java:31)
        at com.huxq17.download.core.task.DownloadTask.downloadWithDownloadChain(DownloadTask.java:99)
        at com.huxq17.download.core.task.DownloadTask.execute(DownloadTask.java:85)
W/System.err:     at com.huxq17.download.core.task.Task.run(Task.java:23)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)
W/System.err: Caused by: java.net.SocketTimeoutException: Read timed out
        at com.android.org.conscrypt.NativeCrypto.SSL_read(Native Method)
W/System.err:     at com.android.org.conscrypt.NativeSsl.read(NativeSsl.java:411)
        at com.android.org.conscrypt.ConscryptFileDescriptorSocket$SSLInputStream.read(ConscryptFileDescriptorSocket.java:549)
        at okio.InputStreamSource.read(JvmOkio.kt:90)
W/System.err:     at okio.AsyncTimeout$source$1.read(AsyncTimeout.kt:129)
    	... 30 more

Can't find on mavenCentral()

Hi,

when I remove //jcenter() from build.gradle(MyProject) I'm have got error:
Could not find com.huxq17.pump:download:1.3.10

Could you please hel me with this issue?

Issue with download

I have an issue with download on some websites.
The file is starting to download but just stuck at 0bytes, and sometimes i need to restart the download. Tried to download with regular browser, the download is working well.

Thank you
image
image

Fatal Exception: android.database.sqlite.SQLiteException: table download_info_temp has 8 columns but 7 values were supplied (code 1):

Fatal Exception: android.database.sqlite.SQLiteException: table download_info_temp has 8 columns but 7 values were supplied (code 1): , while compiling: INSERT INTO download_info_temp SELECT * FROM download_info;
#################################################################
Error Code : 1 (SQLITE_ERROR)
Caused By : SQL(query) error or missing database.
(table download_info_temp has 8 columns but 7 values were supplied (code 1): , while compiling: INSERT INTO download_info_temp SELECT * FROM download_info;)
#################################################################
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1006)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:571)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:59)
at android.database.sqlite.SQLiteStatement.(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1838)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1769)
at com.huxq17.download.db.DBOpenHelper.newVersion4(DBOpenHelper.java:73)
at com.huxq17.download.db.DBOpenHelper.newVersion5(DBOpenHelper.java:93)
at com.huxq17.download.db.DBOpenHelper.onUpgrade(DBOpenHelper.java:136)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:256)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
at com.huxq17.download.db.DBService.getDatabase(DBService.java:132)
at com.huxq17.download.db.DBService.getDownloadInfo(DBService.java:112)
at com.huxq17.download.core.DownloadDispatcher.createDownloadInfo(DownloadDispatcher.java:201)
at com.huxq17.download.core.DownloadDispatcher.createTaskFromRequest(DownloadDispatcher.java:161)
at com.huxq17.download.core.DownloadDispatcher.consumeRequest(DownloadDispatcher.java:72)
at com.huxq17.download.core.DownloadDispatcher.execute(DownloadDispatcher.java:93)
at com.huxq17.download.core.task.Task.run(Task.java:23)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)

When going to releasenew version ?

Hello, looks like in v1.3.10 you dont have current changes that you have on master brach and it dont work on android 11 ?
So, when you going to release new version ? Thanks

conflict by 'ir.metrix:metrix:0.14.4' library

raised error:

Caused by: java.io.IOException: invalid constant type: 19 at 5
at javassist.bytecode.ConstPool.readOne(ConstPool.java:1241)
at javassist.bytecode.ConstPool.read(ConstPool.java:1172)
at javassist.bytecode.ConstPool.(ConstPool.java:185)
at javassist.bytecode.ClassFile.read(ClassFile.java:807)
at javassist.bytecode.ClassFile.(ClassFile.java:148)
at javassist.CtClassType.(CtClassType.java:96)
at javassist.ClassPool.makeClass(ClassPool.java:729)
at javassist.ClassPool.makeClass(ClassPool.java:707)
at javassist.ClassPool$makeClass$0.call(Unknown Source)
at com.buyi.huxq17.ServiceConfig.update(ServiceConfig.groovy:63)
at com.buyi.huxq17.ServiceConfig$update$0.call(Unknown Source)
at com.buyi.huxq17.AgencyTransform.loadJar(AgencyTransform.groovy:138)
at sun.reflect.GeneratedMethodAccessor4188.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:104)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:326)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:352)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:68)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:168)
at com.buyi.huxq17.AgencyTransform$_transform_closure1$_closure5.doCall(AgencyTransform.groovy:62)
at sun.reflect.GeneratedMethodAccessor4185.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:104)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:326)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1041)
at groovy.lang.Closure.call(Closure.java:411)
at groovy.lang.Closure.call(Closure.java:427)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2296)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2281)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2322)
at org.codehaus.groovy.runtime.dgm$186.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:246)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:55)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:127)
at com.buyi.huxq17.AgencyTransform$_transform_closure1.doCall(AgencyTransform.groovy:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:104)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:326)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1041)
at groovy.lang.Closure.call(Closure.java:411)
at groovy.lang.Closure.call(Closure.java:427)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2296)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2281)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2322)
at org.codehaus.groovy.runtime.dgm$186.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:246)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:55)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:127)
at com.buyi.huxq17.AgencyTransform.transform(AgencyTransform.groovy:54)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:239)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:235)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:106)

Why is the English Week not Up to DATE?

This made me lose my time when coding! I could not a setTag(object) method. I see setTag(string) also there is no way of linking a download with an object at the time of request other than a tag. I can not understand Chinese need help here.

Change the path

I have succeeded with moving the files after download finished using Okio and tree uri, but how to change the default path from downloadInfo? Thank you

issue in setting the downloader

sir, I used your downloader it's very useful but I am not able to detect if the file in mp3 video or apk and if the app stops it again shows the downloaded file in downloading the list, as I split the data in two recycler view like ongoing download and completed download it does not refresh at the time

I major problem is with the task should verify what task is it like mp3 video or apk file

please help me with this out.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.