I create a webpage that will download our APK files to Android Smartphone but when I try to do it on Android, I get HTML instead of download window. But it worked perfectly on my PC. Heres my code.
public static void DownloadFile(string filename, string sContentType, System.Web.UI.Page page)
{
string path = page.Server.MapPath(filename); //get file object as FileInfo
System.IO.FileInfo file = new System.IO.FileInfo(path); //-- if the file exists on the server
if (file.Exists)
{
page.Response.Clear();
page.Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
page.Response.AddHeader("Content-Length", file.Length.ToString());
if(sContentType.Length > 0)
page.Response.ContentType = sContentType;
else
page.Response.ContentType = "application/octet-stream";
page.Response.WriteFile(file.FullName);
page.Response.Flush();
page.Response.End(); //if file does not exist
when you say it worked on your pc, do you mean on your pc using an android emulator, or do you mean just going to your website with your browser? What is your target ADV. I am new to android developement but depending on your API level and platform, regulat
html will not render the link on your andoid phone. You are going to need to take additional steps.
Doers get what they want! Everyone else gets what they get.
Well, I am also new to Android, its in my website browser but I used Android phone to open the URL and from there downloading our application MyApp.APK. Its supposed to work the same as downloading Android application from Android Market or GetJar. I used
the code above to download our application but I was not able to do it. What additional steps do I need, I would appreciate it if you can share it with me. Thank you.
Hi Remo, thanks for your quick response. I am using Android Infuse 4g but this is supposed to work with all Android Phones and the application can be installed with any carriers ATT, Verizon, Tmobile and Sprint. Not sure of what the API Level. I have VS
2010 and I just wanted my code would work.
Is the the download window a popup. Is it specifically a modal popup...if it is it won't work on the android phone. You are going to need a redirect to a page with the link or you are going to have to use a java applet. Do you have an emulator? You could
mess around with it and use the emulator to see if it works. The other problem you are going to have is that it may work on certain phones and not others. That is why the emulator is useful. But using an applet will cure all your problems. That or there
might be a java package that has a class that fixes the problem. You may want to post in the android developer forums.
Doers get what they want! Everyone else gets what they get.
If your Android Application is available in Android Market and you are using Android phone, then you can use the following URL format to link your application in the Android Market.
Our application is on our server and I want to download and install it on the Android phone but when I When I tried to download, I get message 'unknown' while downloading, after that I received myApp.htm www.myWebsite.net 3.26kb Download complete
When I Open it, it looked like the mobile site page and when I click again download, nothing happens.
When I clicked Version History or FAQ. I got error Web Page not Available.
content://com.android.htmlfileprovider/mnt/sdcard/download/Version.aspx?Phone=7 could not be loaded
I'm also getting similar problems. I created an android application and posted the .apk onto my server. At first I got 404.3 errors which I handled by adding the mime into the web.config. My PC's download the file no problem but my android devices won't.
My galaxy tab (7 inch) starts to download but then gives me [(Untitled) download unsuccessful] error, and my galaxy tab 10.1 downloads the file but then does nothing. Everything worked fine prior to upgrading my IIS from 5.1 (XP) to 7.5 (Windows 7). Connecting
the device to my PC by USB works fine so I know there's no prob with the app itself. Any suggestions?
Well, after some messing around, I was able to install my app.apk on the galaxy tab 10.1 by navigating to the file location and manually installing it. I'm not sure why the galaxy tab 7 inch won't download the file. At this point I'm still thinking it's
IIS 7.5 that's not allowing it but I have no proof, other than, everything worked fine when I was using IIS 5.1. I'm going to make another server on my XP machine to double check. Stay tuned. ok the problem's fixed...check out the NEXT post..
cortejor
Member
16 Points
16 Posts
Download .APK from Android Phone
Aug 26, 2011 03:19 AM|LINK
I create a webpage that will download our APK files to Android Smartphone but when I try to do it on Android, I get HTML instead of download window. But it worked perfectly on my PC. Heres my code.
public static void DownloadFile(string filename, string sContentType, System.Web.UI.Page page)
{
string path = page.Server.MapPath(filename); //get file object as FileInfo
System.IO.FileInfo file = new System.IO.FileInfo(path); //-- if the file exists on the server
if (file.Exists)
{
page.Response.Clear();
page.Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
page.Response.AddHeader("Content-Length", file.Length.ToString());
if(sContentType.Length > 0)
page.Response.ContentType = sContentType;
else
page.Response.ContentType = "application/octet-stream";
page.Response.WriteFile(file.FullName);
page.Response.Flush();
page.Response.End(); //if file does not exist
}
}
emulator
remojr76
Participant
902 Points
303 Posts
Re: Download .APK from Android Phone
Aug 26, 2011 04:35 AM|LINK
when you say it worked on your pc, do you mean on your pc using an android emulator, or do you mean just going to your website with your browser? What is your target ADV. I am new to android developement but depending on your API level and platform, regulat html will not render the link on your andoid phone. You are going to need to take additional steps.
cortejor
Member
16 Points
16 Posts
Re: Download .APK from Android Phone
Aug 26, 2011 04:59 AM|LINK
Well, I am also new to Android, its in my website browser but I used Android phone to open the URL and from there downloading our application MyApp.APK. Its supposed to work the same as downloading Android application from Android Market or GetJar. I used the code above to download our application but I was not able to do it. What additional steps do I need, I would appreciate it if you can share it with me. Thank you.
remojr76
Participant
902 Points
303 Posts
Re: Download .APK from Android Phone
Aug 26, 2011 05:03 AM|LINK
what API level and platform is the android phone you are using?
cortejor
Member
16 Points
16 Posts
Re: Download .APK from Android Phone
Aug 26, 2011 05:17 AM|LINK
Hi Remo, thanks for your quick response. I am using Android Infuse 4g but this is supposed to work with all Android Phones and the application can be installed with any carriers ATT, Verizon, Tmobile and Sprint. Not sure of what the API Level. I have VS 2010 and I just wanted my code would work.
remojr76
Participant
902 Points
303 Posts
Re: Download .APK from Android Phone
Aug 26, 2011 05:28 AM|LINK
Is the the download window a popup. Is it specifically a modal popup...if it is it won't work on the android phone. You are going to need a redirect to a page with the link or you are going to have to use a java applet. Do you have an emulator? You could mess around with it and use the emulator to see if it works. The other problem you are going to have is that it may work on certain phones and not others. That is why the emulator is useful. But using an applet will cure all your problems. That or there might be a java package that has a class that fixes the problem. You may want to post in the android developer forums.
roopeshreddy
All-Star
20277 Points
3349 Posts
Re: Download .APK from Android Phone
Aug 28, 2011 01:15 AM|LINK
Hi,
If your Android Application is available in Android Market and you are using Android phone, then you can use the following URL format to link your application in the Android Market.
http://market.android.com/search?q=pname:com.voxmobili.phonebook
Check the below links,
http://groups.google.com/group/android-developers/browse_thread/thread/3274a7d722de0aa8#
http://stackoverflow.com/questions/4699035/how-to-redirect-user-to-a-particular-app-in-market
Hope it helps u...
Roopesh Reddy C
Roopesh's Space
cortejor
Member
16 Points
16 Posts
Re: Download .APK from Android Phone
Sep 04, 2011 06:32 PM|LINK
Hi,
Our application is on our server and I want to download and install it on the Android phone but when I When I tried to download, I get message 'unknown' while downloading, after that I received myApp.htm
www.myWebsite.net 3.26kb Download complete
When I Open it, it looked like the mobile site page and when I click again download, nothing happens.
When I clicked Version History or FAQ. I got error Web Page not Available.
content://com.android.htmlfileprovider/mnt/sdcard/download/Version.aspx?Phone=7 could not be loaded
I hope this helps.
Thanks again
S1Niz7el2
Member
8 Points
4 Posts
Re: Download .APK from Android Phone
Oct 09, 2011 01:39 PM|LINK
I'm also getting similar problems. I created an android application and posted the .apk onto my server. At first I got 404.3 errors which I handled by adding the mime into the web.config. My PC's download the file no problem but my android devices won't. My galaxy tab (7 inch) starts to download but then gives me [(Untitled) download unsuccessful] error, and my galaxy tab 10.1 downloads the file but then does nothing. Everything worked fine prior to upgrading my IIS from 5.1 (XP) to 7.5 (Windows 7). Connecting the device to my PC by USB works fine so I know there's no prob with the app itself. Any suggestions?
S1Niz7el2
Member
8 Points
4 Posts
Re: Download .APK from Android Phone
Oct 09, 2011 02:12 PM|LINK
Well, after some messing around, I was able to install my app.apk on the galaxy tab 10.1 by navigating to the file location and manually installing it. I'm not sure why the galaxy tab 7 inch won't download the file. At this point I'm still thinking it's IIS 7.5 that's not allowing it but I have no proof, other than, everything worked fine when I was using IIS 5.1. I'm going to make another server on my XP machine to double check. Stay tuned. ok the problem's fixed...check out the NEXT post..