How to know an Android task's visibility change? -


I have 2 activities that are using the same Android work - that is, they will use the same back stack.

> Call the first activity back in the heap, and call the second activity in the B back stack.

Case 1: A indicates that it goes in the background when A was in the foreground and then < Code> B comes in foreground (for any reason) because it has received an external motive).

Case 2: A goes into the background when A was in the foreground but another application started in the foreground it was done.

Question: How do I differentiate between those 2 cases? What is one way to know that the infection is in the A foreground - & gt; In the background does A keep the current work displayed on the screen?

Actually, I have to get an event when the Android task scene or invisible.

If I understand you correctly, then your activity a If the activity b does not activate after A .

First of all, it is not a good idea to do something about an activity when it is no longer visible. As we see in Android Lifecycle, it can be stopped: Enter image details here

I will keep your background code in a service whenever the activity becomes A or b or starts again, then this service is notified < / P>

Case 1: If you do this, then it happens:

Activity A goes into the background And Your Save In On-Pause Handler Sends a message to A. Service starts its timeout timer activity starts b and sends a message to it. Resume handler service.

Now the services know that it is still the same activity and acts accordingly.

Case 2: Activity A goes into the background and sends the service its timeout timer starts This timeout (I think 200 mms And now your service knows that the work is no longer active and works accordingly.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -