[Q] Android DownloadManager issue - Java for Android App Development

Hello everyone,
for the last few days i'm messing around with DownloadManager in my app. It kinda works, but have some issues. It downloads file fine, but when I try to open file, it say "Can't open file". Here is download manager code from my app:
Code:
Uri source = Uri.parse(url);
DownloadManager.Request request = new DownloadManager.Request(
source);
//Set title and get name file download
//Replace %20 from filename with spaces
request.setDescription("Downloading...");
String split[] = url.split("/");
String filename1 = split[split.length - 1];
String filename2 = filename1.replace("%20", " ");
request.setTitle(filename2);
//Set path for save download file
request.setDestinationInExternalPublicDir(
Environment.DIRECTORY_DOWNLOADS, filename2);
//Show notification in notification bar after download
request.setNotificationVisibility(
DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
manager.enqueue(request);
Thath everyone would understand easier, here is some screenshots with the issue:
As you can see, it downloads file:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
File is downloaded successfully:
However, when I enter "Downloads" it still shows, that the file is still in "Downloading..." state. And when I try to open it, it says "Can't Open file"
And if I enter Downloads directory with "File Manager", I can see it has been completely downloaded, and If i try to open it, it opens just fine.
Maybe anyone knows how to fix it? or where should I look for an error?
P.S. Sorry if its not so clear, but English isn't my native language.
ArnoldasM

Cool. What's the device? Android version?

surlac said:
Cool. What's the device? Android version?
Click to expand...
Click to collapse
Nexus 4, CyanogenMod 11

Nevermind. Found the issue... with status "Downloading...."
request.setDescription..... stupid me....
and if someone facess "Cant open file", you have to set mime type.

Related

A nice tool for our devices, File Explorer Extensio v.2.03 Freeware

This is a freeware that I found by Hou Ming that addresses all the missing features that should have been included in the Windows Mobile stock File Explorer.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Some of the new fatures :
*Resizable header for easy sorting by file name, date of last modification or size
*Tree view of folders; you can now jump easily from a location to any other on your device in one step
*Show extension option for those who ask themselves the same question I do: “What type of file is this?
*Icon view that enables the display of files as icons similar to your desktop computer
*Real time image preview; now you don’t have to open several files in order to send the one you desire
*Open with Program allows you easily select an application to open the specific file you select (useful in case you don’t have the correct file associations or when you want Album app to open your images instead of Windows default picture viewer.
*File property context menu for easy renaming and attribute changing
*Open all executables with Parameters in case you need a special parameter when launching an application
*Sending shortcut to Programs for instant shortcut creation of executables placed directly in Programs folder in Start Menu.
Achtung !
Please search a little before create a new topic
http://forum.xda-developers.com/showthread.php?t=421723
man, someone JUST posted it 2 days ago... come on.
Missing option !
I've installed..and rebooted my htc hermes..but the open with and propery of..are missing from menu..!

[GUIDE]Change APK icon in Windows

I was bored of .apk files either having Winrar icons or simply being a blank slate. This quick little guide changes said icons to anything of your choice.
1) Download FiletypesMan - 32bit, 64bit.
2) Extract this download to another folder and launch FileTypesMan:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
3) Download your preferred icon (.ico files only) which will represent all .apk files. I personally use the following:
.ico version download
4) Note: A majority of the images you will find will be .png, I used the following website to convert it quickly: http://www.convertico.com/
5) While in FileTypesMan go to Edit - New File Extension or press CTRL + T:
6) Enter the following, making sure to choose your required icon and press OK:
7) Verify apk entry, the quickest way being CTRL + F and typing apk:
8) The effect should be immediate and can be tested by viewing any apk file:
Enjoy!
Awesome post, thanks a lot!
Alternatively:
(on XP)
Open an explorer window
go to menu: tools
menu: folder options
tab: file types
look for the .apk file type
click: advanced button
click: change icon button
...et voila!
Thanx
very useful. Thank you

[Q] Spinner help, Eclipses throwing errors!

I'm having trouble populating my Spinner, so I'm using the tutorial on Google website,
http://developer.android.com/resources/tutorials/views/hello-spinner.html
When I get to part 4, and I put the code in the the java folder, a bunch of red X's pop up, giving me errors.
My questions is do I delete everything in the oncreate () .jave file and insert the code from Googles site? When I do it give me errors, this is what happens,
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
I'm know my coding is wrong, can anybody point me in the right direction?
Hold your mouse over that first "Spinner" that is underlined....I bet you get a hint
You're missing a closing '}' tag at the end, it looks like your missing a spinner called "spinner" in your main.xml and it looks like you've not imported 'Spinner' or 'ArrayAdapter'.
I do have a Spinner in my main.xl, I don't have an arrayadapter though
Ok, I fixed 2 parts of the Spinner issue in the first error line,
I imported a Spinner like Root said, than the second error was it was looking for:
findViewById(R.id.spinner);
Than I realize my spinner is not called 'spinner', it was 'spinner1", so I put the 1 on and the error when away.
Now my next issue is the arrary adapter. I know I don't have one in my main.xml, but based on how far im in the tutorial I havent gotten to the part yet which is #5.
EDIT: It's telling me to "Now create a nested class that implements AdapterView.OnItemSelectedListener. This will provide a callback method that will notify your application when an item has been selected from the Spinner."
Where do I implement that?
Bump, please!

[TOOL] Change/Backup your bootanimation with BootMe

Hello everybody !!!
Here is my first program : BootMe.
This program allow you to change or backup your bootanimation easily on your phone.
This program is coded in C++ ( ), use adb and should works on any phone which run Android.
INSTRUCTIONS​
Just unzip the program and run it.
Then, plug your phone on the computer and activate USB Debugging.
Finally, copy your 'bootanimation.zip' file into the folder 'install' and tape 'install' in BootMe.
PREVIEW​
Here is a preview :
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
DOWNLOAD​
BootMe is available in 2 versions, in french or in english, just download the version you need :
BootMe v1.2 (French) : www.ledelete.freeiz.com/zip/BootMe.fr.zip
BootMe v1.2 (English) : www.ledelete.freeiz.com/zip/BootMe.eng.zip
Feel free to leave your impressions or suggestions.
Enjoy !!!
Is there a way to use this with just the phone. I dont use computers anymore. lol. I use my gnote to type papers and everything.
Sent from my SAMSUNG-SGH-I717 using xda app-developers app
Yes, there is a way !!! if you have root explorer, you can just copy your 'bootanimation.zip' into the data/local/ folder of your phone and set the permissions to 644.
There is an other way, you just have to download this application on google play : https://play.google.com/store/apps/details?id=com.simproductions.bachanger&feature=search_result#?t=W251bGwsMSwxLDEsImNvbS5zaW1wcm9kdWN0aW9ucy5iYWNoYW5nZXIiXQ..
Links are dead..!! Can you please update??
You're the first person to use it since one month !!! I will update it when i'll come back home
please update link host file for bootMe 1.2 english! TANK YOU!
This software no longer exists (deprecated).
Sorry

Help plz

I have an android app.I have a preference in my app which allows a user to enter his desired storage location for video recording it can be internal or external now the question is how can i determine if the user has entered the correct storage location path if he didnt enter the right path then how to show a toast and reset the path.
This is the preference
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
This is the editext
Now if the user enters wrong path for example there are spaces in the path or the path is incorrect for video recording how can i check that
Without seeing some code it would be difficult to show you a way that would be easily integrated in to your app.
zalez said:
Without seeing some code it would be difficult to show you a way that would be easily integrated in to your app.
Click to expand...
Click to collapse
Yep, and when is it the "right" path?
The right oath is where a video recording file can be created it can be internal or external
If you've got a file object, you could check these:
Code:
boolean isFile = myFile.isFile();
boolean isDirectory = myFile.isDirectory();
I would implement a chooser instead of relying on your end user to type the correct path.
Take a look at this:
http://www.codeproject.com/Articles/547636/Android-Ready-to-use-simple-directory-chooser-dial
zalez said:
I would implement a chooser instead of relying on your end user to type the correct path.
Take a look at this:
http://www.codeproject.com/Articles/547636/Android-Ready-to-use-simple-directory-chooser-dial
Click to expand...
Click to collapse
Oh, you're right. Much more fool proof. :good:

Categories

Resources