I wanted to know if there is a possibility that we could handle/detect runnable callbacks with delay (postDelayed
method) on android?
For example, I have one or several splashscreen (which runs with handler.postDelayed(new Runnable()...
) on my application (application for testing purpose). In this application I have also a library (that I am creating and using it in the application) and some classes that are available there which runs on an IntentService
class.
Sometimes, when the application is running those splashscreen
Activities (for Testing purpose
), the library that I am creating, might popup some activities automatically in the UI.
But it appears that if those activities comes on a splashscreen
activity and that the splashscreen
is being destroyed, those activities (that popup automatically) will also be destroyed and logging a "leaked window" message in the logcat.
The problem is that :
- those activities that appears automatically in the UI should not be closed automatically, this is prohibited. It needs an interaction from the user for closing that activity and returns to the normal behaviour of the application.
- Also, the library doesn't know anything about the UI of the application.
So my questions are (relatively to the library side that I am creating without having informations to the flow of the UI application):
- Is there a way to detect if some postDelayed method was created in the application relatively to the Library side ? If yes, how could I handle the problem ?
P.S.: Notice that normally, I am using a Dialog for the suppose Activity who is appearing automatically.
UPDATE
Explanation of the diagram :
Right now I have a case that a Splashscreen is being executed.
The class which extends the IntentService class, has received a Request from internet which will start an Activity.
Meanwhile the splashscreen is on postdelayed
, the other Activity has been created and is showing in the UI. When X seconds has passed and the other Activity hasn't been destroyed, the Next Activity is created and destroy the other Activity automatically. In doing that, Android throws a "leaked window" message relatively to the Activity.