Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update an Android app (without Google Play store visit)

I wrote a Beta version of the application. It will be available for download through the web (I will not publish it to the Play Market). Is it possible to update this application without Play Market visit when the new version will be released?

like image 797
IQW Avatar asked Mar 04 '13 23:03

IQW


People also ask

Can you update Android apps without a Google account?

Pre-installed Android apps will soon update even without a Google account. Eventually, when you set up a new Android device, you won't have to sign in to get updates anymore. Google is notifying certain app developers about an upcoming change to the way the Google Play Store distributes app updates (via Android Police) ...

How do I update apps without signing into Google?

It's possible,to do it manually you have to download the last apk of the app you want to update from browser, and then install it, and to do it automatically just install Aptoide, download it from browser, and turn on auto update and give to the app root permissions.


2 Answers

Absolutely. You will need to build a mechanism, though, for your app to call home to the server, find out if there's a newer version of the app, and if there is, pull it down and install it. Once you've determined that you do need to pull down an update, you can do that with something similar to this AsyncTask:

protected String doInBackground(String... sUrl) {     String path = "/sdcard/YourApp.apk";     try {         URL url = new URL(sUrl[0]);         URLConnection connection = url.openConnection();         connection.connect();          int fileLength = connection.getContentLength();          // download the file         InputStream input = new BufferedInputStream(url.openStream());         OutputStream output = new FileOutputStream(path);          byte data[] = new byte[1024];         long total = 0;         int count;         while ((count = input.read(data)) != -1) {             total += count;             publishProgress((int) (total * 100 / fileLength));             output.write(data, 0, count);         }          output.flush();         output.close();         input.close();     } catch (Exception e) {         Log.e("YourApp", "Well that didn't work out so well...");         Log.e("YourApp", e.getMessage());     }     return path; }  // begin the installation by opening the resulting file @Override protected void onPostExecute(String path) {     Intent i = new Intent();     i.setAction(Intent.ACTION_VIEW);     i.setDataAndType(Uri.fromFile(new File(path)), "application/vnd.android.package-archive" );     Log.d("Lofting", "About to install new .apk");     this.context.startActivity(i); } 
like image 96
Blumer Avatar answered Sep 20 '22 17:09

Blumer


Yes it is possible, here is roughly what you can do:

  1. Get the current application versionCode

    PackageInfo packageInfo = getPackageManager().getPackageInfo(context.getPackageName(), 0); int curVersionCode = packageInfo.versionCode; 
  2. Have a server where you host the apk file and create a simple plain file containing only one integer, which represents the latest application version code.

  3. When the app starts (or whenever you want to check for an update), retrieve the latest versionCode from the server (i.e via an HTTP request) and compare it with the current app version.

  4. If there is a new version, download the apk and install it (will prompt a dialog for the user).

Edit:

You can use the code of @Blumer for this.

like image 39
iTech Avatar answered Sep 19 '22 17:09

iTech