Detect the opening of the app

I need to detect when the app is opened, no if the Screen1 is initiated, because it can be initiated but not the first time. To conclude, I need to send a message every time that the app is opened, not when the Screen1 is initiated. I don't know if there is an extension for that.

try the tools extension iand its ActivityStateChanged event

if state = resume
then send message

Taifun

Why, what reason could there be for this?

Because I did a function that checks a googlesheet cell to check if the content of the cell and the value of a variable is the same, to send a notification when the version of the app is not the same and needs to be updated, so I need to send this message only when the app is opened not when the screen1 is initiated, because you can have the app opened and return to the screen1, but then it hasn't needed to send the message.

Ok, so you mean when the app is in the background (e.g. after pressing the Home button) or in idle mode?

Then this extension might help:

Well, it's not that, it's when the app is opened (but it was closed) so I need to detect the activity that the app was opened, I don't know how to do so.

How many Screens in this app, and do any of the other screens open Screen1?

You or the user can see it with their own eyes. So I don't understand at all, where your problem might be. Anyway, try this:

grafik

The problem is that when the user goes to other screens, when they return to the screen1 it puts that it's open again, but I need that only when the app is opened it does that.

There are different ways of switching screens.

If you return to Screen1 by closing a Screen that was opened from Screen1, that would avoid Screen1.Initialize, and be just caught by a When Other Screen Closed event.

1 Like

Screen1:
grafik

Screen2 (and the others):
grafik

Check it with the APK.

Only when you...

I did my homework, and tested both ways, Companion vs built, and indeed this works only in built apps:


open_close_screens.aia (3.8 KB)

Sample built run:
Sample Run in built app

and as noted, it fails in the Companion:
Sample Run in Companion

1 Like

This is a known issure of the companion app for years, see also the notes from here

Current limitations of the AI Companion app:

  1. The close screen block triggers the Initialize event instead of the OtherScreenClosed event.
  2. The close screen with value block triggers both the Initialize and OtherScreenClosed events instead of only the OtherScreenClosed event.
  3. The close application block does not work, a message 'Closing forms is not currently supported during development' will be displayed instead.

Taifun

1 Like

Thanks for this solution, now it works.

Then close the topic.