An open API service indexing awesome lists of open source software.

https://github.com/burgyl/SelfUpdatingApp

An Android Application that can update itself if new releases in GitHub are available.
https://github.com/burgyl/SelfUpdatingApp

android java update update-checker updater

Last synced: about 1 year ago
JSON representation

An Android Application that can update itself if new releases in GitHub are available.

Awesome Lists containing this project

README

          

# Self Updating App
An Android Application that can update itself if new releases in GitHub are available.

Based on [*Implement an in-app update function*](https://medium.com/grandcentrix/implement-an-in-app-updater-1f50fbc38416) by [Tom Seifert](https://medium.com/@Syex).

## Requirements
Works on Android API 21 (5.0, Lollipop) and above (because of [OkHttp](https://github.com/square/okhttp)).
Your releases' tags must be the code version of the app and an APK must be in the binaries.

## What it does
It shows a dialog with the changelog and the name of the last release if a new release is available.

If the user clicks OK :
- Android 7 and above: Downloads and installs the APK
- Below Android 7 : Downloads the APK, the user has to go to the notifications to install it

The dialog isn't shown if the release doesn't have an APK.

## Installation

### Gradle dependencies

Add this in your gradle dependencies :
```
implementation 'com.squareup.okhttp3:okhttp:4.6.0'
implementation 'com.squareup.moshi:moshi:1.9.3'
implementation 'com.squareup.okio:okio:2.8.0'
```

### Manifest

In the Manifest, add these permissions in the manifest tag :
```xml

```
And add this provider in the application tag :
```xml

```

### Java

Add the entirety of the package `selfupdate`.

In the onCreate of your activity, add this to check if there is an update at the start of the application :

```java
if (savedInstanceState == null)
SelfUpdate.checkUpdate(this, "burgyl", "SelfUpdatingApp");
```

or this if you support API before 21 :

```java
if (savedInstanceState == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
SelfUpdate.checkUpdate(this, "burgyl", "SelfUpdatingApp");
```

You have to adapt the above username and repository.

### Resources

Add the layouts for the dialogs :
```
layout/content_dialog_download.xml
layout/content_dialog_show_update.xml
```

Add the values :
```
values/dimens.xml
values/strings.xml
```

And add the file provider paths :
```
xml/file_provider_paths.xml
```

## Licenses & Credits

- [Moshi](https://github.com/square/moshi) by [Square Open Source](https://square.github.io/), licensed under the Apache 2.0 license
- [OkHttp](https://github.com/square/okhttp) by [Square Open Source](https://square.github.io/), licensed under the Apache 2.0 license
- [Okio](https://github.com/square/okio) by [Square Open Source](https://square.github.io/), licensed under the Apache 2.0 license