Giter Site home page Giter Site logo

handyupate-android's Introduction

#HandyUpdate A simple version update for android app.

Usage

At first :

Add dependencies in build.gradle.

	dependencies {
	   compile 'wang.jack.update.library:library:1.0'
	}

An simple example use:

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

    HandyUpdate.update(this,url);
}  

default json return should be like

{
    "updateInfo": {
        "appName": "name",
        "appDescription": "description",
        "packageName": "com....",
        "versionCode": 9,
        "versionName": "1.08",
        "apkUrl": "http://..."
        }
}

or you can implements it with yourself json.

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

    HandyUpdate.setCustomParseListener(new HandyUpdate.UpdateParseListener() {
        @Override
        public UpdateInfo getUpdateInfo(String yourselfJson) {
            //like this
            UpdateInfo updateInfo=new UpdateInfo();
            JSONObject jsonObject=new JSONObject(yourselfJson);
            updateInfo.appName=jsonObject.optString("appName");
            ....
            updateInfo.apkUrl=jsonObject.optString("apkUrl");
            return updateInfo;
        }
    });
    HandyUpdate.update(this, url);
}

Configuring

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

    UpdateParam updateParam=new UpdateParam.Builder(this)
            .setUpdatePrompt(true)//if current version was latest, show prompt or not
            .setApkPath(apkPath)
            .setBackgroundService(false)//if true ,download task will be run through service
            .setCheckPackage(false)
            .build();
    HandyUpdate.update(this, url, updateParam);
}

Tips

  • if version was downloaded ,should be not download again ,this will be solve future ,of course ,welcome send PR if you can help this.

Thanks

##Contact me

if you have a better idea on this project or way, please let me know, thanks:)

Email

Weibo

handyupate-android's People

Contributors

harlonwang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.