Recent

Author Topic: create new android module  (Read 4086 times)

m4u_hoahoctro

  • Full Member
  • ***
  • Posts: 160
create new android module
« on: March 29, 2015, 11:17:46 am »
I have android module 1 and android module 2, and in android module1, i put a button and add this code:
uses... unit2;
...
procedure TAndroidModule1.jButton1Click(Sender: TObject);
begin
  androidmodule2.show;
end;

When I test on my phone, I click on button and nothing happens, module 2 doesn't appear and then app auto closes

Why ? And how to fix it
thanks.

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: create new android module
« Reply #1 on: March 29, 2015, 06:21:20 pm »
Hi m4u_hoahoctro, please, try:

Code: [Select]
  if(AndroidModule2 = nil) then
  begin
      gApp.CreateForm(TAndroidModule2, AndroidModule2);
      AndroidModule2.Init(gApp);
  end
  else
  begin
    AndroidModule2.Show;
  end;

Thank You!

PS. You can try open "AppTest1" Demo..... for more info ....
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

m4u_hoahoctro

  • Full Member
  • ***
  • Posts: 160
Re: create new android module
« Reply #2 on: March 30, 2015, 06:50:00 am »
what is "gapp" ?

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: create new android module
« Reply #3 on: March 30, 2015, 07:17:02 am »

gApp -->> Global [Pascal Android] Application ....
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

m4u_hoahoctro

  • Full Member
  • ***
  • Posts: 160
Re: create new android module
« Reply #4 on: March 30, 2015, 12:53:00 pm »
if(AndroidModule2 = nil) then
  begin
      gApp.CreateForm(TAndroidModule2, AndroidModule2);
      AndroidModule2.Init(gApp);
  end

may this code mean if I don't have androidmodule2, it will create it ?

m4u_hoahoctro

  • Full Member
  • ***
  • Posts: 160
Re: create new android module
« Reply #5 on: March 30, 2015, 04:14:03 pm »
and I also have a prolem
if code as this: both modules display in time
how can i hide module1 ? and only show module2 ?

if(AndroidModule2 = nil) then
  begin
      gApp.CreateForm(TAndroidModule2, AndroidModule2);
      AndroidModule2.Init(gApp);
  end
else
  begin
    androidmodule1.Close;
    AndroidModule2.Show;
  end;     

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: create new android module
« Reply #6 on: March 30, 2015, 04:23:07 pm »
@m4u_hoahoctro

Quote
...I have android module 1 and android module 2, and in android module1, i put a button and add this code:
uses... unit2;

So, I understood that you had androidmodule2, if not then you need to create it:

Lazarus IDE -->> File -->> New... -->Module --> Android DataModule

Now You can use this code to create/initizalize [or show]:

Code: [Select]
  if(AndroidModule2 = nil) then
  begin
      gApp.CreateForm(TAndroidModule2, AndroidModule2);
      AndroidModule2.Init(gApp);
  end
  else
  begin
    AndroidModule2.Show;
  end;
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: create new android module
« Reply #7 on: March 30, 2015, 04:30:28 pm »

Quote
how can i hide module1 ? and only show module2 ?

1. Set module2 BackGroundcolor <> transparent/default !
2. Set molule2 ActivityMode = actRecyclable

Do not close module1 [actMain] by code!

Thank you!

PS 1. Please, use the new wizard entrypoint "JNI Android Module (GUI)" to create new project...

PS 2. I just now renamed the old entrypoint to "JNI Android Module (not GUI)" [under devolopment!] ... Sorry
« Last Edit: March 30, 2015, 05:43:41 pm by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

m4u_hoahoctro

  • Full Member
  • ***
  • Posts: 160
Re: create new android module
« Reply #8 on: March 31, 2015, 04:25:32 pm »
thanks, but I think i also use code androidmodule1.finish;  :)

 

TinyPortal © 2005-2018