I am not able to close my App (only one screen)

Both should work if "checkTrue" returns true.

1 Like

Yes, obviously the 1st implementation had only the 2nd if but did not work so I add the if to close the screen that if present should be executed before to close the application. So, I totally I agree with you, I should need only the 2nd if but it does not work and I don't understand why. I could suspect that the problem can arise from another part of the code but there are no warnings e no errors so it is difficult to understand where it comes from... I am just guessing

1 Like

Post a test aia.

1 Like

This is the minimum app that does not close clicking on the button... at least on Android 11R.
TestCloseApp.aia (1.4 KB)

1 Like

I built your test app and it works fine on Samsung Galaxy A51 running Android 11.
Which device are you using for your tests?
You might want to use logcat to find out, why it does not work on your device...

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

1 Like

This block

grafik

works on all Android versions and devices, at least when no other screens are open.
But it does not remove the app from recent apps:

2 Likes

The version code name of Android 11 is R:

grafik

There is no special Android 11R version.

Android 9 → P(ie):

Info on the smartphone says version name = "Android 11 R" api level = 30 build number=AN3516-camelia-build-20210809205128 built tile=09 august 2021 14:54:33 CEST ID build= RP1A.200720.011

I already used it and for it there is no problems at all... as for it the app closes well. But I am sure is strange because with companion it emits the message that closing the application is blocked in development mode so at least it tries to execute the code. I tested with a LG-K8 running Android 8 and it works, instead running on a POCO M3 Pro 5G does not. In practice it is a Xiaomi model running MIUI Global 12.0.10.0(RKSEUXM) that is Android 11 RP1A.200720.011. The smartphone model code for Xiaomi is M2103K19PG

As I said, there is no special Adroid 11R version.
Try this app (Companion or APK) and post a screenshot.
AndroidVersionCodeName.aia (5.8 KB)

grafik
Should look like this:

grafik

I just replied with the info I see to say you why I wrote Android 11 R, nothing more. About the extension you adviced: it works and solves the problem, not only removes the app from recent apps but the app closes correctly... I do not why or if there is something related to "close application" but it works. Would you need any information to investigate a little bit more or do you think I can close this thread? Ok, it is not an optimal solution (some users may not like to remove the app also from the recent apps list) but for me it is OK at 99%.

And I just wanted to clear up a possible misunderstanding for you and others.

Fine, but extremely strange, however.
Does the app close when the device back button is pressed?

Yes, now it closes pressing the back button also. Before it did not. I have a bar with an exit button (the user has to press it and confirm he wants to exit pressing yes on the notifier that pops up or pressing no to continue). Yes, it is strange, when happened the 1st time I was surprised and I thought may be I did not see an error but I had 0 errors and 0 warnings then I supposed may be related to an extension so I wrote the minimum aia I sent you but also that did not close correctly so I searched the forum and the web for possible bugs/known errors/workarounds and I added the 2nd if (that to close the screen) but nothing changed. I may suppose there is some sort of interaction between closing the app and remove from recent apps, something as if I do not remove it "Android" restarts the app, but I am just thinking and guessing.

Does it only happen with AI2 apps that the app is not closed when the back button is pressed?
That would be a novelty that I have never heard of before.

Well... generally speaking I did not remember an app tha does not close among those I use but I remember I removed a couple of apps that did not work as expected and also I had problems to close them. Now I am ending the test of the app with the "reference device" and so I will repeat them with others running on Android 8 and 10, I can test with and without removing the app from the recent apps list and see if anything changes.

Try this:

Does it work?

grafik

No, it does not work. The app does not close and it is also present in the recent apps list.

Ok, then the same result with Kodular ... really strange ...
But actually it should then happen with all apps and not just with AI2 apps, because most apps do not remove the apps from the recent apps.

Btw, to be clearer for everyone, "Android 11 R" is a pleonasm like a "dead corpse".

Makes sense but I do not know how the apps I installed are made but I could try to make a minimum app with Android Studio or Xamarin or C++ Builder and see what happens.

You could also try the MoveTaskToBack method from the notification extension

Taifun