apk installation from web page - android

I'm looking for a sample web page (html code) with a link that will install an apk file directly on my phone by clicking on the link.

Just link to the apk file in the HTML. It couldn't be any simpler.
link
You will have to have "install apps from unknown sources" enabled on your phone.

If you're using ASP.NET, then you'll need to insert the following in your web.config file:
<configuration>
...
<system.webServer>
<staticContent>
<mimeMap fileExtension=".apk"
mimeType="application/vnd.android.package-archive" />
</staticContent>
</system.webServer>
...
</configuration>
Apart from that (as others have said), you just need a normal link:
Click here
and tell your users to enable the Security -> Unknown sources option in Settings.

Extra help for IIS webservers: mbaird's example worked great for me after I added the apk mime type to my IIS webserver. I just put an html file up with that link, but got a 404 error when trying to pull up my test.apk file without the .apk mime entry. As Commonsware said, make sure to allow .apk files in the mime types - this is for sure still necessary on an IIS webserver. You can do this from IIS Manager, select the server, and find "Mime Types", then add an entry.

In .Net this is what I did, I created an .asmx page then a QR code that pointed to it
other wise I kept getting a 404, then this on page load.
protected void Page_Load(object sender, EventArgs e){
ViewState["PreviousPage"] = Request.UrlReferrer;
string filepath = Server.MapPath("AcsMainMenu.apk");
FileInfo droidfile = new FileInfo(filepath);
if (droidfile.Exists)
{
Response.ClearContent();
Response.AddHeader("Content-Disposition", "attachment; filename=" + droidfile.Name);
Response.AddHeader("Content-Length", droidfile.Length.ToString());
Response.ContentType = "application/vnd.android.package-archive";
Response.TransmitFile(droidfile.FullName);
Response.Flush();
Response.End();
Response.Redirect(ViewState["PreviousPage"].ToString());
}
}

Related

How to implement email adapter for Parse to allow password reset feature

Problem description
I am using AWS EC2 to host my bitnami parse server which acts as the backend for my android app. I am having trouble implementing password reset for the users of my app. I have followed the instructions from:
https://github.com/parse-community/parse-server#email-verification-and-password-reset
But I still get the error:
"com.parse.ParseRequest$ParseRequestException: An appName, publicServerURL, and emailAdapter are required for password reset and email verification functionality."
Step by step of what I did
I went to mailgun and created an account.
I registered a domain that I own (hosted by squarespace) to mailgun. (see picture below)
I went to my server.js file located in the apps/parse/htdocs folder.
I modified my server.js file to look like this, shown below.
Then in my android application, I called a test password reset using the following code.
Things I am unsure of
I haven't physically installed anything such as the simple-mailgun-adapter. I tried to follow this link: https://github.com/parse-community/parse-server-simple-mailgun-adapter. and install
npm install --save #parse/simple-mailgun-adapter to my apps/parse/htdocs folder. But I got a whole bunch of errors. Shown below.
I'm not sure what the publicServerURL is in the server.js file. I assumed it is the same thing as serverURL, so if you look at my server.js file, both serverURL and publicServerURL have the same input.
Please let me know if you guys can spot any errors I made. I've been working on this for a week, and still can't get password recovery working. Thank you!
A few things:
If your package.json has
"parse-server-simple-mailgun-adapter":"1.0.0",
under the dependencies section, then the package should be installed automatically. I usually check under the node_modules folder.
The resetPassword error is saying you are missing the appName parameter. You need to add it to your server config object:
var config = {
...
publicServerURL: (process.env.SERVER_URL || 'http://localhost:1337') + mountPath,
// Your apps name. This will appear in the subject and body of the emails that are sent.
appName: 'YOURAPPNAME',
...
Your publicServerURL is usually something like server.domain.com. It helps since people resetting their password will be redirected to a webpage on the domain where they will enter a new password. It's nice for users if the domain reflects something they can trust...
Hope this helps.
add {} in your package.json as it should not be empty.

Play framework: file download

I try to make a file server to let people download APK file.My server is using Play framework.
the problem is :I always download a "app" file without file extension by PC browser.while using android browser, I always download a "app.bin" file. Is there anything wrong with my code?
test link:test download
public static Result get_app() {
File tmp = new File("Ele.apk");
response().setHeader("Content-Disposition", "attachment; filename=Ele.apk");
response().setContentType("mime/type");
return ok(tmp);
}`
There's no such Content-Type as mime/type or mime/apk as you trying to use it in the sample...
By Wikipedia description APK's Content-Type is application/vnd.android.package-archive and probably this one you should set.
If problem remains try to google what is valid Content-Type for serving these keys.

A filed download doesn't initiate from my Android app

I am currently building an Android app using HTML5. Inside my app, I am providing link to a HTML file available inside tomcat server on my machine.
<div>Beep</div>
The HTML file "sample.html" has link to download a file in same file location, where the sample.html is placed.
sample.html has this --> Click to download
The problem here is, when I run my app on an android mobile, the link stays dumb and it won't initiate the download from the given path.
But, the same URL when I open in a web browser, the download starts.
Could anyone let me know why this URL is not initiating the download inside my app??
I already enabled "Allow installation of non-Market applications" in the settings of my android device.
If you are using real device you must set your url with static ip of your machine like 192.168.0.10 and in emulator 10.0.0.2
See this post.
Use 10.0.2.2 as IP for server running on the same machine as the Android emulator.
Check out following post with similar problem:
Download File inside WebView
Check out this link for setting up the mime type in tomcat.
Copied for reference:
In Tomcat 5.x and 4.x, the default mappings between MIME types and file extensions are stored in the file tomcat_home/conf/web.xml, where tomcat_home is the path under which Tomcat was installed on your server. The mappings specified there are applied to all web / WAP applications hosted on your Tomcat server. Application-specific mappings should be set in the WEB-INF/web.xml file under the directory of your web / WAP application.
Each mapping is specified with the <mime-mapping>, <extension> and <mime-type> tags. Here is an example:
<web-app>
...
<mime-mapping>
<extension>xhtml</extension>
<mime-type>application/vnd.wap.xhtml+xml</mime-type> </mime-mapping>
<mime-mapping>
<extension>wml</extension>
<mime-type>text/vnd.wap.wml</mime-type> </mime-mapping>
<mime-mapping>
<extension>wmls</extension>
<mime-type>text/vnd.wap.wmlscript</mime-type> </mime-mapping>
<mime-mapping>
<extension>wbmp</extension>
<mime-type>image/vnd.wap.wbmp</mime-type> </mime-mapping>
...
</web-app>

invalid url error with phonegap

I just started a project with phonegap and I m getting a "invalid url error" message box + app crash on a html link to "http://maps.google.fr" (external link) , It works without problem on IPhone..
any ideas why?
The latest code has the new white-list feature. If you are referencing external hosts, you will have to add the host in PhoneGap.plist under the "ExternalHosts" key. Wildcards are ok. So if you are connecting to "http://phonegap.com", you have to add "phonegap.com" to the list (or use the wildcard "*.phonegap.com" which will match subdomains as well).

Can't install APK hosted my own apache server

I've exported an apk from eclipse. I am able to install it without any problem if I copy it to the phone's sd card.
When trying to download via phone's (Galaxy S) browser I get:
"Download unsuccessful".
I have set mime type application/vnd.android.package-archive in the mime.types, restarted apache, still same result.
Also tried :
Download App
Still no luck.
I am able to download and install applications from android market. I suspect that apache is not sending the mime type but this is just a shot in the dark.
How can I fix the problem and be able to install APKs from my web server? (or at least to check if apache sends correct header with mime type)
Any help will be appreciated.
It is better if you add the .apk extension to the apache`s mime config. Take a look at this example:
https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
You can just find the "apk" record and copy the row to the file /etc/mime.types at your server:
application/vnd.android.package-archive apk
Also add this to /etc/apache2/mods-available/mime.conf :
AddType application/vnd.android.package-archive .apk
(There are some other AddType-s, put it after them for sure).
From here on you don't have to put anything for the apk`s mime-type in the tag, the server will handle this. ;)
UPDATE: fixed a bug in AddType line
After all I found the problem thanks in part to CommonsWare advise.
Directory where I put apks for downloads is protected by simpe auth. Phone's browser correctly asks (once) for username/password when browsing it but obviously forgets to send auth info when trying to download the file and that causes 401 Unauthorized.
Solution: remove basic auth from that dir or use another unprotected dir for the apks.
Use curl to test the Web server to make sure it is responding to the HTTP request and returning the proper MIME type. Also, example your server logs to see what error is being logged.
Sometimes you have no access to apache configuration files like /etc/mime.types, especially on the shared servers. You can create file .htaccess (or open if it already exists) in your root directory and add the following string:
AddType application/vnd.android.package-archive .apk
Hope it helps.

Categories

Resources