Navdroid
Navdroid

Reputation: 1549

How to download a file from a website to an SD card

Everybody must have seen on Google Play that whenever we click install button on the website the particular app is downloaded and installed on the android device owned by user. How could I possibly do that on my android app and website i.e If the user logon to my website with his gmail Id and buys a product (which are some data files) and those files are downloaded to the sdcard of the android device. Have any one worked on similar technique and how it could be possible. Please help?

Upvotes: 1

Views: 746

Answers (2)

minhaz
minhaz

Reputation: 4233

You are combining couple of problems together.

  1. Log in to the website using Gmail Account
  2. Download the app onto SD Card
  3. Install the app.

Android will try to install any binary extension with .apk when you click on it. So even from your email attachment you will be able to download a apk file to sd card and install it onto the device.

You can sell an individual items through your website. Standard solution would be to set up in app purchase through Google play or implement something similar. Alternatively From your app you can complete this sign on and purchase and download whatever place you like.

Edit 1

You can simply use multiple Activities to facilitate additional item purchase.

  1. Log in activity (will help with login process)
  2. ListView (to show user a nice available items list)
  3. When user select an item use some payment system to complete the transaction
  4. When you receive payment successful notification download items to user sd card. see this for help link.

Alternatively you can use webview and HTML to complete above scenarios.

Upvotes: 0

Pratik
Pratik

Reputation: 30855

One way is you can implement GCM(Google Could Message) for sending the request to the device from server now by getting the request of installation get the URL/URI of that application and download it in device. Once the download was completed you can install this apk file by using this code

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File
            (Environment.getExternalStorageDirectory()  + "/yourapk.apk")), "application/vnd.android.package-archive");
startActivity(intent);

This way you can implement this feature in your website.

Note: For this device has one application for this to get the message from GCM and implement based on this like Google has Google Play Store. User must install your application for this.

Upvotes: 1

Related Questions