This is very simple project i did.. basically for new to android programming people who do not have play account but want to somehow deploy necessary update to their app ,,
This library uses Firebase database...
It will automatically give you a update, function like download the apk file and then open it automatically to install.. or like whether the update is forced or not.... If there is an forced update..your app won't run unless user update it..
This library automatically manages downloading of apk file,managing write permission and also file providers to locate and open apk to install via content:// uri instead of file://
This library helps you to easily deploy update just by updating links in Firebase node ... For more information read the readme.md
1. Connect your app to Firebase and Enable Realtime Database at Firebase Console
after connecting app to Firebase via Android studio,,goto firebase console and navigate to project there and enable realtime database.
while enabling the real time database try in `test mode` i.e both the read and white permission are true
dependencies {
classpath 'com.google.gms:google-services:4.2.0'
//this is required1
}
repositories {
...
maven { url 'https://jitpack.io' }
}
apply plugin: 'com.google.gms.google-services' //this is required 2
and
please use the latest Release version to ensure Compability
dependencies {
implementation 'com.github.authoritydmc:UpdateAppSupport:1.0.1'
}
import authoritydmc.UpdateApp;
1.1 Call via method checkupdate
UpdateApp.checkupdate(Context context,String currentVersionname,boolean shouldShowDialog);
where currentVersionname can be Passed via Either using BuildConfig.VersionName or
via calling getCurrentVersion();
method getCurrentVersion() should be implemented first .
or
StartActvitiy(new Intent(context, authoritydmc.UpdateApp.class));
-
name
String
:- name of your app -
isforced
boolean
:- Whether the Current Version is forced or not.if isforced is true then app cannot run without updating.. Please note that this requires calling to checkupdate method inside Main or any parent activity (base activity ) -
version
String
:-what will be version number of next update (All update logic depend on this number .) choose any higher number than current build version to allow update -
size
String
:- size of next update app file -
app_download_url
String
:-url of the apk file -
icon_url
String
:- url of icon of app
- context is Context passed from calling Activity
- currentVersioname is Current Build Version of App (ex: "0.1.2")
- shouldShowDialog is a boolean value .if true a Dialogue Box appear in the calling activity if there is an update else just a toast is shown if it is false
private String getCurrentVersion() {
//get the current version number and name
String versionName = "";
int versionCode = -1;
try {
PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
versionName = packageInfo.versionName;
versionCode = packageInfo.versionCode;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return versionName;
}