I am using DownloadManager to download video file from internet to Environment.DIRECTORY_MOVIES. File is being downloaded, and when the download finishes I get ACTION_DOWNLOAD_COMPLETE broadcast.
But when I check download status there i get STATUS_FAILED back with REASON 406, which should be HTTP Error 406 Not acceptable. Also DownloadManager automatically deletes that file so I am not able to access it any more.
Strange thing is that it works on most devices and this is happening on Sony D5503 with android 5.1.1.
Do you have any idea why this can happen please?
Related
I'm using a local server on my Android device to cast images + mp4s to Chromecast.
(I tried both - NanoHttpD and AndroidAsyncHttpServer) https://github.com/MikeMitterer/android-cromecastsample/tree/master/src/main/java/at/mikemitterer/mobile/chromecastsample/cast (GH-Repo)) but if I server the files from one of these local servers I get Status{statusCode=unknown status code: 2100, resolution=null}
Serving the files from an external server works - at least with a MP4-File.
This is the the server I'm currently using: https://github.com/MikeMitterer/android-cromecastsample/blob/master/src/main/java/at/mikemitterer/mobile/chromecastsample/cast/CastAsyncFileServer.java
The Activity that initializes everything: https://github.com/MikeMitterer/android-cromecastsample/blob/master/src/main/java/at/mikemitterer/mobile/chromecastsample/ui/MainActivity.java
and my buildMediaInfo-function: https://github.com/MikeMitterer/android-cromecastsample/blob/master/src/main/java/at/mikemitterer/mobile/chromecastsample/ui/MainActivity.java#L317-L341
This shows how the sample app looks like:
Clicking on one of the images triggers the loadRemoteMedia -> buildMediaInfo.
I'm using the Chromecast V1 (old) Device on a 22" Monitor (No Audio with HDMI to DVI Converter) Streaming with other Apps than mine works. Im using the sample-app ID (4F8B3483) for testing.
BTW: (my second problem) If I use my own registered ID Chromecast connects fine but automatically disconnects after approximately 20secs...
I'm a bit lost - please help!
[Update]
Thanks to # Ali Naddaf I re-registered my Application!!! not the device! I changed from "Remote Display Receiver" to "Styled Media Receiver" waited ~15mins turned off/on Chromecast now debugging works and my second problem, that Chromecast automatically disconnected after ~20secs, is also solved. Cool!
If you check my SS you can see that my image is set as background for the video-tag. Is this the way it should work or I am doing something wrong?
Following the REST API, I encounter an error while using the PUT method through retrofit call. The error occurs only in Lollipop version of android whereas it works fine on the other O.S. as tested thoroughly . I am sending data in the body of the request and while debugging it , it shows that the body has been successfully sent but the server does not receive it . The error occurs randomly as it may or may not work . What could be the possible reason and solution?
I'm trying to download the following file using DownloadManager:
http://loopstream01.apa.at/?channel=fm4&ua=flash&id=2013-10-05_1902_tl_54_4DDSat1__9778.mp3
The code looks like this:
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(asset.url));
request.setDescription("");
request.setTitle(asset.name);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "test");
DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
manager.enqueue(request);
The download manager always fails to download the file with the following error message:
Aborting request for download 123: http error 206
Since 206 means partial content and this always requires a range in the http request I added
request.addRequestHeader("Range", "bytes=0-1000");
to download the first 1000 bytes but the error message stays the same and nothing is downloaded. :(
Edit When I run the same code on an Android 4.2 device I'm getting the following message:
10-09 21:22:41.461: I/DownloadManager(2379): Download 231 starting
10-09 21:22:41.692: W/DownloadManager(2379): Aborting request for download 231: Expected OK, but received partial
10-09 21:22:41.712: I/DownloadManager(2379): Download 231 finished with status CANNOT_RESUME
It appears as though the android download manager handles a 206 resume response if it believes it is resuming an earlier download.Otherwise it will assume the response is invalid.
Explicit range requests inserted through addRequestHeader will not work.
Here's the download thread code for 4.3.1:
https://android.googlesource.com/platform/packages/providers/DownloadProvider.git/+/android-4.3.1_r1/src/com/android/providers/downloads/DownloadThread.java
I'm using the DownloadManager to queue up some downloads I'm making but running into this issue when I specifically try to use the Mobile/4G connection. I'm using an Android 2.3.4 phone. My code is using the 2.3.3 API.
I'm doing the following command (I want to force the connection to use 4G/3G)
request.setAllowedNetworkTypes(Request.NETWORK_MOBILE);
Whenever it attempts to download however, it places the download in the DownloadManager listing but it forever remains in the status "In progress" and an error at the top lists the file name and the error "Download requires network."
When I investigate further and connected my device to see the logs in logcat, I see the following error when it attempts to download:
Aborting request for download 92: download was requested to not use the current network type
I have the following permissions:
android.permission.WRITE_OWNER_DATA
android.permission.READ_OWNER_DATA
android.permission.WRITE_EXTERNAL_STORAGE
android.permission.INTERNET
android.permission.ACCESS_NETWORK_STATE
android.permission.ACCESS_WIFI_STATE
android.permission.CHANGE_WIFI_MULTICAST_STATE
android.permission.CHANGE_NETWORK_STATE
android.permission.CHANGE_WIFI_STATE
Any ideas of what it could be? Am I still missing a permission? Is there another setting that I need to control to specify the use of the Network connection only?
EDIT:
I have tried this on a brand new Galaxy tablet and this is the behavior I notice using this device: When the wifi is on and connected, it fails to download when specifying to use the NETWORK_MOBILE. If the wifi is turned off or not connected, it has no problem using the 4G connection. I'm thinking this is a security feature being done by the device, can this be overidden?
I dont know how you are setting up your download manager but this is how ive used it in the pass.
private long enqueue;
private DownloadManager dm;
public void onClick(View view) {
dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
Request request = new Request(
Uri.parse("File URL"));
enqueue = dm.enqueue(request);
}
public void showDownload(View view) {
Intent i = new Intent();
i.setAction(DownloadManager.ACTION_VIEW_DOWNLOADS);
startActivity(i);
}
This error occurs when you have no data connection (doesn't matter whether or not you are connected to wifi). You are allowed to specify NETWORK_MOBILE by itself, but it will throw you an error saying "Download Requires Network" if it tries to do the download when your data connection isn't currently working.
My advice to get a data connection again is to walk around until you get a connection again. I can tell when I have a data connection on my Droid Bionic phone because the top bar icons that say 4G LTE and the 4 bars turn blue instead of white.
I originally posted this question to the Android developers Google group a few days ago, but have yet to hear a response. Maybe someone on Stack Overflow can help?
I have an app which streams mp3s from the web, proxied through a local HTTP server. At times, this local proxy server returns an HTTP error. It seems that upon receiving this error during the prepare state, the MediaPlayer makes one more attempt to stream, sending another request to the URL specified in setDataSource().
From a thread, I'm calling MediaPlayer.prepare() once. But from the proxy thread, I can see that after sending an HTTP error response, another request for the same URL is made. Can someone confirm this behavior? I'm seeing this from the emulator running a 1.6 AVD.
Can I disable this automatic retry? Is there a specific HTTP error code that I can send that will prevent this retry?
Thanks!