S
S
sitev_ru2015-08-26 06:51:46
Android
sitev_ru, 2015-08-26 06:51:46

How to determine the status of the application, that it is minimized?

You need to determine that the application is minimized (depending on this, the application will perform different actions).

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Andrey, 2015-08-26
@sitev_ru

There is such a wonderful ActivityLifecycleCallbacks class. Here is a good example of usage: baroqueworksdev.blogspot.ru/2012/12/how-to-use-act...
The idea is this: in your class that implements ActivityLifecycleCallbacks, we start a counter that will count the number of started / stopped activities and the method a -for isAppInForeground().

private int startStatus = 0;
...
    @Override
    public void onActivityStarted(Activity activity) {
        ++startStatus;
    }

    @Override
    public void onActivityStopped(Activity activity) {
        --startStatus;
    }

    public boolean isAppInForeground() {
        return startStatus > 0;
    }

R
Robert, 2015-08-26
@NgNl

onPause
onWindowFocusChanged
here is the solution
well and explore

A
Alexey, 2015-08-26
@vaseel1ch

it, isn't it?

V
Valodemorz, 2017-12-18
@Valodemorz

Only here is the trouble, onStop may not be called. The last method guaranteed to be called is onPause

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question