Recent

Author Topic: Open Another Form LAMW Android  (Read 625 times)

spacepascal

  • Newbie
  • Posts: 5
Open Another Form LAMW Android
« on: November 04, 2024, 04:15:30 pm »
I changed PC and i reinstalled LAWM in a new PC. Usually i used this code to Open Another form, but for somewhat reason is not working anyway. Also in the past i had some trouble to open the others forms but i resolved the issue with this code, especially with the "close;" line.
Code: Pascal  [Select][+][-]
  1.    if AndroidModule2 = nil then
  2.      begin
  3.        gApp.CreateForm(TAndroidModule2, AndroidModule2);
  4.        AndroidModule2.InitShowing();
  5.      end;
  6.     Close;
Right now this code don't work anymore. Why? There is a single place where to learn lamw programming?

I tested the code in Android 14
Thanks to all the heros who want to help me!!

c4p

  • Full Member
  • ***
  • Posts: 166
Re: Open Another Form LAMW Android
« Reply #1 on: November 04, 2024, 08:08:13 pm »
My code to create the form, and force to the front, I am using Android 14.:

Code: Pascal  [Select][+][-]
  1.       if (AndroidModule2 = nil) then
  2.         begin
  3.           gapp.CreateForm(TAndroidModule2, AndroidModule2);
  4.           AndroidModule2.Init();
  5.           AndroidModule2.MoveTaskToFront();
  6.         end;

Code to show the form:

Code: Pascal  [Select][+][-]
  1.    AndroidModule2.Show;    

I also have the second form in the uses clause of the controls.lpr
The MoveTaskToFront can probably be put just before the show, not sure why I put it there, I must have had a reason  :)
Lazarus 2.0.12 r64642/FPC 3.2.0 LAMW v0.8.6.4 on Windows 10+Linux Mint 21.2, projects mainly built using AppCompat and Gradle.

spacepascal

  • Newbie
  • Posts: 5
Re: Open Another Form LAMW Android
« Reply #2 on: November 04, 2024, 11:23:02 pm »
I don't know why but don't work for me. There are some changes in LAMW in the form initialization?

dseligo

  • Hero Member
  • *****
  • Posts: 1421
Re: Open Another Form LAMW Android
« Reply #3 on: November 04, 2024, 11:48:49 pm »
What does happen? Do you have error or crash?

This is code from one of my test apps, it is similar to c4p's code:
Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.AndroidModule1ActivityCreate(Sender: TObject; intentData: jObject);
  2. begin
  3.   If AndroidModule2 = nil then
  4.   begin
  5.     gApp.CreateForm(TAndroidModule2, AndroidModule2);
  6.     AndroidModule2.DoJNIPromptOnInit := False;
  7.     AndroidModule2.BackgroundColor := colbrGhostWhite;
  8.     AndroidModule2.Init;
  9.   end;
  10. end;
  11.  
  12. procedure TAndroidModule1.btnForm2Click(Sender: TObject);
  13. begin
  14.   AndroidModule2.Show;
  15. end;

spacepascal

  • Newbie
  • Posts: 5
Re: Open Another Form LAMW Android
« Reply #4 on: November 05, 2024, 05:42:50 pm »
This last example seem to work well, why the others don't work? No error nor others issues. Strange behavior maybe there was an update in LAMW Form initialization i don't know.

dseligo

  • Hero Member
  • *****
  • Posts: 1421
Re: Open Another Form LAMW Android
« Reply #5 on: November 05, 2024, 06:26:45 pm »
This last example seem to work well, why the others don't work? No error nor others issues. Strange behavior maybe there was an update in LAMW Form initialization i don't know.

Difference between c4p's and mine example is that I explicitly set form's background color - backgrounds in Android are transparent by default.

That is the reason I asked what does happen exactly. I.e.: nothing is shown, a crash, overlapping of elements from first and second form, ...

c4p

  • Full Member
  • ***
  • Posts: 166
Re: Open Another Form LAMW Android
« Reply #6 on: November 05, 2024, 10:22:20 pm »
100% correct, I have my Background on the second form set to Black / coblBlack.
Transparency by default causes so many issues.

This last example seem to work well, why the others don't work? No error nor others issues. Strange behavior maybe there was an update in LAMW Form initialization i don't know.

Difference between c4p's and mine example is that I explicitly set form's background color - backgrounds in Android are transparent by default.

That is the reason I asked what does happen exactly. I.e.: nothing is shown, a crash, overlapping of elements from first and second form, ...
Lazarus 2.0.12 r64642/FPC 3.2.0 LAMW v0.8.6.4 on Windows 10+Linux Mint 21.2, projects mainly built using AppCompat and Gradle.

 

TinyPortal © 2005-2018