Not Working
See original GitHub issueI tried out the library and it’s not working.
Here’s my code
class MainActivity : AppCompatActivity() {
// fetchListener code, removed, for the sake of brevity.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val url = "http://www.alexszepietowski.com/wp-content/uploads/downloads/2013/03/The%202%20Golden%20Rules%20of%20Property,%20Business%20and%20Life!.pdf"
val fileName = "MyFile.pdf"
val dirPath = "/FileDownloader/PDF/$fileName"
val fetchConfiguration = FetchConfiguration.Builder(this)
.setDownloadConcurrentLimit(3)
.build()
val fetch = Fetch.getInstance(fetchConfiguration)
val request = Request(url, dirPath)
request.priority = Priority.HIGH
request.networkType = NetworkType.ALL
request.addHeader("clientKey", "SD78DF93_3947&MVNGHE1WONG")
fetch.addListener(fetchListener)
fetch.enqueue(request)
}
fun Log(msg: String) {
android.util.Log.d("MainActivity", msg)
}
}
AndroidManifest.xml
<manifest
... >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
...>
...
</application>
</manifest>
Log output
D: FetchListener. onError. Error = UNKNOWN_IO_ERROR, Download = DownloadInfo(id=-1721883501, namespace='LibGlobalFetchLib', url='http://www.alexszepietowski.com/wp-content/uploads/downloads/2013/03/The%202%20Golden%20Rules%20of%20Property,%20Business%20and%20Life!.pdf', file='/FileDownloader/PDF/MyFile.pdf', group=0, priority=HIGH, headers={clientKey=SD78DF93_3947&MVNGHE1WONG}, downloaded=0, total=-1, status=FAILED, error=UNKNOWN_IO_ERROR, networkType=ALL, created=1536016053913, tag=null, enqueueAction=REPLACE_EXISTING, identifier=0, downloadOnEnqueue=true, extras={})
you can check out my full code here -> https://github.com/Edge-Developer/FetchDownloadManagerIssue
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (4 by maintainers)
Good fetch is working.
Cache directory is a sandboxed directory in your application folder. I used this example because sandboxed directories do not require
PERMISSIONS
to write to it. Just so you know cache directory can be found at/Android/data/
.I rewrote your sample app to request permissions and write to the root
DOWNLOAD
folder like you are expecting.https://github.com/sethchhim/FetchDownloadManagerIssue/commit/c083874844ca9f6949f749b2b004eac7f8f7aedf
The commit is the code, I will paste here for you.
val dirPath = "$cacheDir/FileDownloader/PDF/$fileName"