Skip to content

this is project for android application update own

License

Apache-2.0, Apache-2.0 licenses found

Licenses found

Apache-2.0
LICENSE
Apache-2.0
LICENSE.txt
Notifications You must be signed in to change notification settings

MDL-Sinlov/MDL_Android_Updater

[TOC]

MDL Android Updater

  • this library is deconstruction updater
  • use single instance in reducing memory usage
  • can define check and setting
  • use android download manager, so package is less method count

version 0.1.0 method count 58

Less Runtime :

eclipse just use every repo at version updater-x.x.x-jarLib.zip

Project Runtime:

  • Android Studio 2.2.3
  • appcompat-v7:23.4.0
  • Gradle 2.14
  • com.android.tools.build:gradle:2.2.3

Last Update Info

  • version 0.1.0

add method at Updater setForciblyUpdate isForciblyUpdate isMobileUpdate

Dependency

at root project build.gradle

repositories {
    maven {
        url 'https://raw.githubusercontent.com/MDL-Sinlov/MDL-Android-Repo/master/mvn-repo/'
    }
    jcenter()
    ...
}

in module build.gradle

dependencies {
    compile 'mdl.sinlov.android:updater:0.1.0'
}

Usage

base use

first setting you want update

private class UpdateCheckSetting extends UpdateSetting {

        public UpdateCheckSetting(ICheckUpdate checkUpdate) {
            super(checkUpdate);
        }

        @Override
        public void update() {
            // base update
            Updater.getInstance().updateOwn();
        }

        @Override
        public void forciblyUpdate() {
            // you can show forcibly update UI at here
            showForciblyUpdateUI();
            Updater.getInstance().updateOwn();
        }

        @Override
        public void silentUpdate() {
            // you can show silent update UI at here
            Updater.getInstance().updateOwnSilent();
        }

        @Override
        public void noUpdate() {
            // no update you want do
            Toast.makeText(MainActivity.this, "No Update", Toast.LENGTH_SHORT).show();
        }
    }

then init update check

Updater.getInstance().init(this.getApplication(), new UpdateCheckSetting(
                new CheckUpdate(false, 2, "mdl.sinlov.android.updater", "http://192.168.1.107:8082/app-debug.apk")));

class CheckUpdate Constructor

  • boolean isForciblyUpdate true is force
  • int versionCode server return versioncode
  • String updatePackageName server return packageName, can use ""
  • String updateURL server return update URL, it will be check

you can use class CheckUpdate or define by yourself at implements ICheckUpdate

after above these setting update you app

// show is your app can update
Updater.getInstance().isCanUpdate();
// update you app if do not want show download, set true
Updater.getInstance().update(false);

use this method to retry install after download finish

// installAPKByDownload return true is download success
if (!Updater.getInstance().installAPKByDownload()) {
    Updater.getInstance().updateOwn();
}

Custom setting

MyCheckUpdate

  • you can define your check
private class MyCheckUpdate implements ICheckUpdate {
        @Override
        public boolean isForciblyUpdate() {
            //TODO you can set forcibly update true is force
            return true;
        }

        @Override
        public int updateVC() {
            vc = 2;
            return vc;
        }

        @Override
        public String updatePN() {
            //TODO check pn at this place if not check use ""
            return "mdl.sinlov.android.updater";
        }

        @Override
        public String updateURL() {
            //TODO update url it check by URL
            return "http://192.168.1.107:8082/app-debug.apk";
        }
}
  • set download notification clicked toast words
UpdaterDownloadCallBack.setDownloadNotificationClickStr("My click words");
  • set your want define notification clicked
UpdaterDownloadCallBack.setOnNotificationClicked(new UpdaterDownloadCallBack.OnNotificationClicked() {
                    @Override
                    public void onClick(Context context, Intent intent) {
                        Toast.makeText(context, "My New Call Back", Toast.LENGTH_SHORT).show();
                    }
                });

notes: if you setting custom notification clicked default toast will not show.

  • DefaultPackageInstaller can install apk or uninstall an APP

#License


Copyright 2016 [email protected]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

this is project for android application update own

Resources

License

Apache-2.0, Apache-2.0 licenses found

Licenses found

Apache-2.0
LICENSE
Apache-2.0
LICENSE.txt

Stars

Watchers

Forks

Packages

No packages published

Languages