| java.lang.Object |
| ↳ |
com.steerpath.sdk.utils.Foreground |
Class Overview
Usage:
1. Get the Foreground Singleton, passing a Context or Application object unless you
are sure that the Singleton has definitely already been initialised elsewhere.
2.a) Perform a direct, synchronous check: Foreground.isForeground() / .isBackground()
or
2.b) Register to be notified (useful in Service or other non-UI components):
Foreground.Listener myListener = new Foreground.Listener(){
public void onBecameForeground(){
// ... whatever you want to do
}
public void onBecameBackground(){
// ... whatever you want to do
}
}
public void onCreate(){
super.onCreate();
Foreground.get(this).addListener(listener);
}
public void onDestroy(){
super.onCreate();
Foreground.get(this).removeListener(listener);
}
Summary
| Fields |
|
public
static
final
String |
TAG |
|
|
[Expand]
Inherited Methods |
From class
java.lang.Object
|
Object
|
clone()
|
|
boolean
|
equals(Object arg0)
|
|
void
|
finalize()
|
|
final
Class<?>
|
getClass()
|
|
int
|
hashCode()
|
|
final
void
|
notify()
|
|
final
void
|
notifyAll()
|
|
String
|
toString()
|
|
final
void
|
wait(long arg0, int arg1)
|
|
final
void
|
wait(long arg0)
|
|
final
void
|
wait()
|
|
From interface
android.app.Application.ActivityLifecycleCallbacks
|
abstract
void
|
onActivityCreated(Activity arg0, Bundle arg1)
|
|
abstract
void
|
onActivityDestroyed(Activity arg0)
|
|
abstract
void
|
onActivityPaused(Activity arg0)
|
|
abstract
void
|
onActivityResumed(Activity arg0)
|
|
abstract
void
|
onActivitySaveInstanceState(Activity arg0, Bundle arg1)
|
|
abstract
void
|
onActivityStarted(Activity arg0)
|
|
abstract
void
|
onActivityStopped(Activity arg0)
|
|
Constants
public
static
final
long
CHECK_DELAY
Constant Value:
500
(0x00000000000001f4)
Fields
public
static
final
String
TAG
Public Constructors
Public Methods
public
static
Foreground
get
(Application application)
public
static
Foreground
init
(Application application)
Its not strictly necessary to use this method - _usually_ invoking
get with a Context gives us a path to retrieve the Application and
initialise, but sometimes (e.g. in test harness) the ApplicationContext
is != the Application, and the docs make no guarantees.
Returns
- an initialised Foreground instance
public
boolean
isBackground
()
public
boolean
isForeground
()
public
void
onActivityCreated
(Activity activity, Bundle savedInstanceState)
public
void
onActivityDestroyed
(Activity activity)
public
void
onActivityPaused
(Activity activity)
public
void
onActivityResumed
(Activity activity)
public
void
onActivitySaveInstanceState
(Activity activity, Bundle outState)
public
void
onActivityStarted
(Activity activity)
public
void
onActivityStopped
(Activity activity)