• Stars
    star
    153
  • Rank 243,368 (Top 5 %)
  • Language
    Java
  • License
    Other
  • Created over 9 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Utility for detecting and notifying when your Android app goes background / becomes foreground

Foredroid

Download

Utility for detecting and notifying when your Android app goes background / becomes foreground.

API-level 14+.

logo

Usage:

Initialise Foreground as early as possible in the startup of your app:

public void onCreate(Bundle savedInstanceState){
  Foreground.init(getApplication());
}

Any time you want to check if you are foreground or background, just ask:

Foreground.get().isForeground();
Foreground.get().isBackground();

Or, if you want to trigger something as soon as possible when you go background or come back to foreground, implement Foreground.Listener and do whatever you want in response to the callback methods:

Foreground.Listener myListener = new Foreground.Listener(){
  public void onBecameForeground(){
    // ... whatever you want to do
  }
  public void onBecameBackground(){
    // ... whatever you want to do
  }
}

... then register your listener:

listenerBinding = Foreground.get().addListener(listener);

Note that in registering the listener we recorded the Binding that was returned, so that we can unbind it again later:

listenerBinding.unbind();

Maven / Gradle

The .aar file is available from the jcenter repository. Check that you have the jcenter repository in your top-level build.gradle like this:

allprojects {
    repositories {
        jcenter()
    }
}

Add the following dependency to your build.gradle:

compile 'com.sjl:Foredroid:1.0.2'

More Repositories

1

opencv-android

Android Library Project for OpenCV (currently v3.x.y)
Java
113
star
2

jetty-embedded-spring-mvc

Example project for setting up embedded Jetty 9 with Spring-MVC, JSP and JSTL support (uses Maven).
Java
66
star
3

AsyncAndroid

Example code for Android Concurrency book (ISBN 978-1-78328-687-4)
Java
42
star
4

jetty-embedded-spring-mvc-noxml

Jetty 8 embedded / Spring-MVC 3.1.2 - no xml configuration
Java
33
star
5

react-native-circular-slider-example

A bit of React-Native SVG fun, inspired by a stackoverflow question
Objective-C
30
star
6

Android-Download-Service-Example

An example of implementing RSS downloads using an IntentService - see http://stackoverflow.com/questions/6343166/android-os-networkonmainthreadexception
Java
30
star
7

dsl4xml

Easy and fast marshalling of XML And JSON to Java objects via a DSL that mirrors the document structure.
Java
28
star
8

nextjs-nested-layouts

JavaScript
14
star
9

dsl4xml-perf

Performance & comparison tests for dsl4xml
Java
8
star
10

vectoriser

bitmap to svg tracer, written in java
Java
7
star
11

sjl.io

IO utils (java)
Java
5
star
12

implicit-futures

experimental implementation of implicit futures in java (using dynamic proxies and java's explicit java.util.concurrent.Future)
Java
5
star
13

manual-ntlm

node.js scripts to help with manually testing NTLM auth via telnet / openssl
JavaScript
3
star
14

gwt-progressive

Progressive Enhancement lib for GWT
Java
2
star
15

sjl.util

simple utility classes (java)
Java
2
star
16

gwt-rubiks

3d rubiks cube rendered on html canvas using javascript (via GWT)
Java
2
star
17

circular-slider-expo

ReactNative circular slider example (expo version)
JavaScript
2
star
18

vagrant-boxes

some handy vagrant box definitions
Shell
2
star
19

sjl.testing

Some test-related utils
Java
2
star
20

dsl4xml-perf-android

Android project for running dsl4xml perf tests on a device
Java
2
star
21

steveliles.github.com

my blog
HTML
1
star
22

sjl.regex

regex based utils (java)
Java
1
star
23

Artwork

Graphics and Artwork
Shell
1
star
24

kafkaish

Poor-man's Apache-Kafka - replay-able publish/subscribe event streams on MongoDB
JavaScript
1
star