Recent

Author Topic: LAMW - Controls/Activity disappear from app after Home/Recent  (Read 594 times)

Manlio

  • New member
  • *
  • Posts: 31
  • Pascal dev
I'm using the latest version of lamw and laz4android 1.8 (attached a screenshot, I hope I'm doing this right...)

I open a demo project, e.g. AppCompatCollapsingToolbars1, compile it, and deploy it to my phone, by pressing Ctrl-F1 (Compile and install APK)

The app now opens nicely in my phone (screenshot on the left)

I press the Home button on the phone, and the app goes away.  Then I press the "Recent" button, and I see the app in the task manager (screenshot in the middle).

I tap on the app to reopen it, and it does reopen, but now everything has disappeared from it, all the controls are gone, the app is blank. (screenshot on the right)

I've tried with different demo projects, different combinations of settings in the manifest (e.g. I tried all the android:launchMode settings, and various other related settings) but I cannot get the app to reopen with its controls visible after using the Home button or even the Recent button or the Back button.

The phone runs Android 8.1. Same thing with another phone running Android 7.0.

Can anyone kindly help?
manlio mazzon gmail

jmpessoa

  • Hero Member
  • *****
  • Posts: 1371
Re: LAMW - Controls/Activity disappear from app after Home/Recent
« Reply #1 on: April 14, 2019, 03:50:25 pm »

HI, Manlio.

I'll try to reproduce here and propose some solution....

Thank you!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Manlio

  • New member
  • *
  • Posts: 31
  • Pascal dev
Re: LAMW - Controls/Activity disappear from app after Home/Recent
« Reply #2 on: April 14, 2019, 04:24:38 pm »
Thank you!

If it helps, here is the whole folder after the build, including the APK file. (I only removed the big folder build\intermediates which I think is not needed)

https://drive.google.com/file/d/11u5Bzh6kD-Re6C4ZTdEkxzrHwB_v_1dE/view?usp=sharing

Again, thank you so much for any help!
manlio mazzon gmail

jmpessoa

  • Hero Member
  • *****
  • Posts: 1371
Re: LAMW - Controls/Activity disappear from app after Home/Recent
« Reply #3 on: April 15, 2019, 08:34:40 am »

Hi, Manlio.

I could not reproduce here .... but you can try "ReInit()" the form handling these events:

"OnJNIPrompt"  or  "OnResume"   [depending on the logic of your application....]

Code: Pascal  [Select]
  1. procedure TAndroidModule1.AndroidModule1JNIPrompt(Sender: TObject);    //this fire first...
  2. begin  
  3.    Self.ReInit(gApp);   // <---- try it!
  4. end;
  5.  

or

Code: Pascal  [Select]
  1. procedure TAndroidModule1.AndroidModule1ActivityResume(Sender: TObject);  // //this fire after
  2. begin
  3.   Self.ReInit(gApp);   // <---- try it!
  4. end;  
  5.  
 
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Manlio

  • New member
  • *
  • Posts: 31
  • Pascal dev
Re: LAMW - Controls/Activity disappear from app after Home/Recent
« Reply #4 on: April 15, 2019, 05:02:58 pm »
Thank you!

Calling ReInit on Resume makes the controls visible again :)

At the same time, the problem is not completely resolved, the behaviour of some controls is a little changed...

For example, if I have a jMediaPlayer which is playing something, if I call ReInit() on the Resume event, the app will crash. Anyway now I will study what happens inside of ReInit and maybe if I understand better what is going on, I can solve the problem in a better way.

Can I ask you one more favour, jmpessoa? Actually, two favours... :)

1. Can you tell me what are the versions of Java, JDK, NDK, Lazarus, and FPC that you are using? I will try to reinstall everything using the exact same versions that you are using, and maybe things will work better.

2. You said you cannot reproduce the bug. In that case, can you please build one of your demo project (for example, AppCompatCollapsingToolbars1, and then zip the whole folder of the project, including the APK, and upload it somewhere so I can get it? In this way I can compare a compiled version that works with my version (that doesn't work without ReInit) -- I will compare manifest files, java files, APK files, etc. and hopefully I will learn something useful to solve this problem at the root. And of course I'll share here everything I learn that might be useful to others.

In any case thank you very much for the kind help and for developing LAMW!

M.M.



manlio mazzon gmail

las

  • New member
  • *
  • Posts: 22
Re: LAMW - Controls/Activity disappear from app after Home/Recent
« Reply #5 on: May 10, 2019, 10:54:27 pm »
Hi!
ReInit () works if one form is used. At the same time it is necessary to form a background of colors. If the BackgroundColor is left colbrDefault, then when it starts to draw with the overlay.

If the application has several forms and exit the application to the desktop by pressing Home, while not on the main form, and then restarting the application, we get an empty screen. If we place ReInit () on the second form, the form is not empty, but the return to the main form does not work when you click Back.

Manlio

  • New member
  • *
  • Posts: 31
  • Pascal dev
Re: LAMW - Controls/Activity disappear from app after Home/Recent
« Reply #6 on: May 12, 2019, 11:15:40 am »
I have factory reset my 2 test phones and I have reinstalled the entire LAMW environment, and the problem doesn't happen any more.

So... solved with a lingering aura of mystery.
manlio mazzon gmail

las

  • New member
  • *
  • Posts: 22
Re: LAMW - Controls/Activity disappear from app after Home/Recent
« Reply #7 on: May 12, 2019, 12:46:40 pm »
Hi!

I discovered the pattern of the problem.
1. Compile and install the application on the phone by Ctrl + F1.
2. In the running application, click Home.
3. Run the application from the desktop of the phone and see a blank screen, in which only the name of the application is written at the top.
4. Click Back.
5. After that, when restarting, everything works fine, even if the application is deleted in the phone’s task manager.

ReInit (gApp) helps to solve the problem only with the main form of the application.

Phone Xiaomi Note 3 pro. Android 6.0.1