Recent

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

Manlio

  • New member
  • *
  • Posts: 7
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?

jmpessoa

  • Hero Member
  • *****
  • Posts: 1293
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: 7
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!

jmpessoa

  • Hero Member
  • *****
  • Posts: 1293
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: 7
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.