Skip to content
This repository has been archived by the owner on May 22, 2021. It is now read-only.
/ AppStatus Public archive

An Android Library to retrieve standalone service status

License

Notifications You must be signed in to change notification settings

codechimp-org/AppStatus

Repository files navigation

AppStatus How to include

An Android Library that will check a given URL for a JSON or XML file containing current service status. Use the returned message and priority to display appropriate user information within your app.

Host your service status file (json or xml) wherever you like publicly so your app can check the current status. If you have a backend you can automatically monitor simply publish the new file, otherwise do it by hand for known lengthy outages.

Inspired by https://github.com/javiersantos/AppUpdater a great version checking solution.

API

How to include

Add the repository to your project build.gradle:

repositories {
    maven {
        url "https://jitpack.io"
    }
}

And add the library to your module build.gradle:

dependencies {
    implementation 'com.github.codechimp-org:AppStatus:1.0.2'
}

Usage

AppStatus appStatus = new AppStatus(this)
        .setUpdateFormat(UpdateFrom.JSON)
        .setUpdateURL("https://raw.githubusercontent.com/codechimp-org/AppStatus/master/samplestatus.json")
        .withListener(new AppStatus.StatusListener() {
            @Override
            public void onSuccess(Status status) {
                // Handle displaying your message and priority here
                Log.d(TAG, status.getMessage());
            }

            @Override
            public void onFailed(AppStatusError error) {
                // Do your error handling here, could be incorrect URL, bad json or xml, or network issue
            }
        });

appStatus.start();

See the sample app for a larger example using the SnackBar.

Status Files

Status files can either be JSON or XML. Message and Priority are both string values and the library does not do anything intelligent with them so can be set/interpreted however you want within your application.

status.json
{
  "message": "Services Out",
  "priority": "High"
}
status.xml
<status>    
    <message>Services Slow</message>
    <priority>Low</priority>
</status>

License

Copyright 2018 CodeChimp

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.