Anuj TBE
Anuj TBE

Reputation: 9790

Android check for new update without play store

I am Googling from last week but I didn't found any tutorial which could help me.

I am working on an Android App, and have joined Android Development just a few days ago, it means I am new here.

I have developed an App that perform certain tasks like send email, send message, etc.

I am not going to host my App on Google Play Store, because I think its not the right time to do it. This means I am hosting my app on my own server.

I want to put update checking on my app so that, It will inform the user as soon as a new version is available on the server.[Running in Background]

Also, there is a Check for Update button on about page, which when clicked, will check for whether update available or not and notify user to download if available.

Please, help me out. As I am new here, so try to be precise, step by step guide will be appreciable.

Upvotes: 2

Views: 3135

Answers (3)

Anuj TBE
Anuj TBE

Reputation: 9790

I got working solution to my question.

Here is what I did to get it work...

1 . Download WVersionManager from github

Download Link : Click Here

download wversionmanager

2 . Extract downloaded file in a folder on desktop (or any directory of your wish)

enter image description here

3 . Copy Latest Version of WVersionManager.java from java directory

WVersionManager.java

4 . Open your android project and expand libs folder and right click and paste

copy paste in lib folder


after paste

paste wversionmanager.java in lib

5 . Open your layout.java file in which you want to add the fuctionality (eg., activity_main.java or make a new class file as update.java. and paste update code ofter onCreate()

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        WVersionManager versionManager = new WVersionManager(this);
        versionManager.setVersionContentUrl("http://link_to_version_test_file/version.txt");
        versionManager.setUpdateUrl("http://link_to_updated_apk_file/latest.apk");
        versionManager.checkVersion();

This code will check for update each time application is started and a new update is available it will inform user with a pop-up.

6 . Add update with a button click

update can also be assigned to a button click, ie., if user clicks button it will check for new update.

public class about extends ActionBarActivity {

    Button updateButton;

    @Override
    protected void onCreate (Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.about);

        updateButton = (Button)findViewById(R.id.button_Update);

        updateButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
        WVersionManager versionManager = new WVersionManager(this);
        versionManager.setVersionContentUrl("http://link_to_version_test_file/version.txt");
        versionManager.setUpdateUrl("http://link_to_updated_apk_file/latest.apk");
        versionManager.checkVersion();
            }
        });
    }

7 . Contents of version.txt file

The version.txt contains these codes :

{"version_code":6,"content":"Version 1.5 <p>Added feature 1</p><li>Added feature 2</li><li>Added feature 3</li><li>Added feature 4</li><li>Added feature 5</li>"}

version_code and content:version is your application's version code and version name respectively as mentioned in manifest file.

to add more features, just add <li>Added feature title</li>

8 . Giving Internet permission to your app

Add these lines to your application's manifest file.

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

9 . Thats it.... You are done now..

Now check your application, it must be working.

NOTE : You can add more customization to update script, check extracted folder for more detail. Hope this will work for others also.

I have tested it on android 2.3 and android 4.3 version and its working.

Upvotes: 2

Display Name
Display Name

Reputation: 8128

You should add a click listener to your button, that would execute some code that will send a request to your server, telling him which version is used right now, and the server will compare it to the current version and send back the result (are the versions equal or not, and if they are not equal, it can also send the download link for the actual version).

Step by step guide:

  • Implement the logic on the server side.
  • Implement the request sending code in your app.
  • Implement the request receiving code in your app.
  • Set click listener to the button, it should invoke the code you wrote in step 2.
  • Implement file downloading using the link received in step 3. (and you can also open the downloaded file automatically)

Caveat:

You don't need anything of the above if you upload your app to Google Play™. Think again, is it worth it?

Update 1

Don't forget to make sure that your server uses HTTPS and you check the certificate validity when connecting to it.

Upvotes: 2

Solution is simple. Write a webservice for checking the latest app version. In your application, compare the version number from webservice with your currently installed version number programmatically. If the version code from webservice is bigger than other, call your "Check for Update" medhod and show that your app has a new version.

Upvotes: 1

Related Questions