Recent

Author Topic: Android Module Wizard  (Read 705477 times)

greenzyzyzy

  • Full Member
  • ***
  • Posts: 249
Re: Android Module Wizard
« Reply #405 on: May 14, 2015, 07:11:33 am »
Hi  m4u_hoahoctro,

Here is a modified "unit2.lfm"

Code: [Select]
object AndroidModule2: TAndroidModule2
  Left = 945
  Top = 48
  Width = 300
  Height = 600
  MarginLeft = 0
  MarginTop = 0
  MarginRight = 0
  MarginBottom = 0
  Text = 'AndroidModule2'
  ActivityMode = actMain
  BackgroundColor = colbrDefault
  OnJNIPrompt = AndroidModule2JNIPrompt
  object jTextView1: jTextView
    Left = 5
    Top = 5
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    PosRelativeToAnchor = []
    PosRelativeToParent = [rpTop, rpLeft]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView1Click
    Id = 3718151
  end
  object jTextView2: jTextView
    Left = 76
    Top = 5
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView1
    PosRelativeToAnchor = [raToRightOf]
    PosRelativeToParent = [rpTop]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'B'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView2Click
    Id = 9461189
  end
  object jTextView3: jTextView
    Left = 147
    Top = 5
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView2
    PosRelativeToAnchor = [raToRightOf]
    PosRelativeToParent = [rpTop]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'C'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView3Click
    Id = 6341291
  end
  object jTextView4: jTextView
    Left = 218
    Top = 5
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView3
    PosRelativeToAnchor = [raToRightOf]
    PosRelativeToParent = [rpTop, rpRight]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'B'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView4Click
    Id = 5522042
  end
  object jTextView5: jTextView
    Left = 5
    Top = 76
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView1
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpLeft]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView5Click
    Id = 7622216
  end
  object jTextView6: jTextView
    Left = 76
    Top = 76
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView5
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = []
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView6Click
    Id = 8770245
  end
  object jTextView7: jTextView
    Left = 147
    Top = 76
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView6
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = []
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView7Click
    Id = 7830331
  end
  object jTextView8: jTextView
    Left = 218
    Top = 76
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView7
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = [rpRight]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView8Click
    Id = 1969942
  end
  object jTextView9: jTextView
    Left = 5
    Top = 147
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView5
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpLeft]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView9Click
    Id = 2190527
  end
  object jTextView10: jTextView
    Left = 76
    Top = 147
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView9
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = []
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView10Click
    Id = 4756362
  end
  object jTextView11: jTextView
    Left = 147
    Top = 147
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView10
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = []
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView11Click
    Id = 2589130
  end
  object jTextView12: jTextView
    Left = 218
    Top = 147
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView11
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = [rpRight]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView12Click
    Id = 0
  end
  object jTextView13: jTextView
    Left = 5
    Top = 218
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView9
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpLeft]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView13Click
    Id = 1752964
  end
  object jTextView14: jTextView
    Left = 76
    Top = 218
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView13
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = []
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView14Click
    Id = 15784
  end
  object jTextView15: jTextView
    Left = 147
    Top = 218
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView14
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = []
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView15Click
    Id = 5912469
  end
  object jTextView16: jTextView
    Left = 218
    Top = 218
    Width = 61
    Height = 61
    MarginLeft = 5
    MarginTop = 245
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView15
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = [rpRight]
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpOneEighthOfParent
    Text = 'A'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrChartreuse
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    OnClick = jTextView16Click
    Id = 2866691
  end
  object jTextView17: jTextView
    Left = 98
    Top = 289
    Width = 103
    Height = 32
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 10
    MarginBottom = 5
    Visible = True
    Anchor = jTextView15
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpCenterHorizontal]
    LayoutParamWidth = lpWrapContent
    LayoutParamHeight = lpWrapContent
    Text = 'The Answer:'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrDefault
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    Id = 9929159
  end
  object jButton1: jButton
    Left = 82
    Top = 330
    Width = 136
    Height = 40
    MarginLeft = 2
    MarginTop = 4
    MarginRight = 2
    MarginBottom = 4
    Visible = True
    Anchor = jTextView17
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpCenterHorizontal]
    LayoutParamWidth = lpHalfOfParent
    LayoutParamHeight = lpWrapContent
    Text = 'Start'
    BackgroundColor = colbrDefault
    FontColor = colbrDefault
    FontSize = 0
    OnClick = jButton1Click
    Id = 4885599
  end
  object jButton2: jButton
    Left = 82
    Top = 378
    Width = 136
    Height = 40
    MarginLeft = 2
    MarginTop = 4
    MarginRight = 2
    MarginBottom = 4
    Visible = True
    Anchor = jButton1
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpCenterHorizontal]
    LayoutParamWidth = lpHalfOfParent
    LayoutParamHeight = lpWrapContent
    Text = 'Surrender'
    BackgroundColor = colbrDefault
    FontColor = colbrDefault
    FontSize = 0
    OnClick = jButton2Click
    Id = 1744465
  end
  object jTextView18: jTextView
    Left = 216
    Top = 289
    Width = 61
    Height = 32
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jTextView17
    PosRelativeToAnchor = [raToRightOf, raAlignBaseline]
    PosRelativeToParent = []
    LayoutParamWidth = lpOneQuarterOfParent
    LayoutParamHeight = lpWrapContent
    Text = '00 : 00'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrNavajoWhite
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    Id = 0
  end
  object jSpinner1: jSpinner
    Left = 8
    Top = 432
    Width = 287
    Height = 40
    MarginLeft = 5
    MarginTop = 10
    MarginRight = 5
    MarginBottom = 10
    Visible = True
    Anchor = jButton2
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = []
    LayoutParamWidth = lpMatchParent
    LayoutParamHeight = lpWrapContent
    Items.Strings = (
      'Hi'
      'Hello'
      'Bye bye'
    )
    BackgroundColor = colbrDefault
    SelectedFontColor = colbrDefault
    DropListTextColor = colbrDefault
    DropListBackgroundColor = colbrDefault
    LastItemAsPrompt = False
    FontSize = 0
    Id = 7525840
  end
  object jTextView19: jTextView
    Left = 103
    Top = 487
    Width = 94
    Height = 32
    MarginLeft = 5
    MarginTop = 5
    MarginRight = 5
    MarginBottom = 5
    Visible = True
    Anchor = jSpinner1
    PosRelativeToAnchor = [raBelow]
    PosRelativeToParent = [rpCenterHorizontal]
    LayoutParamWidth = lpWrapContent
    LayoutParamHeight = lpWrapContent
    Text = 'Hello Baby'
    Alignment = taCenter
    Enabled = True
    BackgroundColor = colbrWhiteSmoke
    FontColor = colbrBlack
    FontSize = 20
    TextTypeFace = tfNormal
    Id = 0
  end
  object jTextFileManager1: jTextFileManager
    left = 40
    top = 152
  end
  object jTimer1: jTimer
    Enabled = False
    Interval = 1000
    OnTimer = jTimer1Timer
    left = 104
    top = 152
  end
end

why my build apk can not run?codes no problem,compile ok,build apk ok,but run app does not show any component,only a blank window.

LoneVoice

  • Newbie
  • Posts: 2
Re: Android Module Wizard
« Reply #406 on: May 14, 2015, 02:29:57 pm »
Hi,

Is there a way to get position and size of a component? Right now Left/Top/Width/Height properties only return value from fields and not the real position of components in most cases.

I also tried to add component to form/custom dialog using code but failed. Can anyone show me a working example so I can study?

The last thing is we can change color of a button, but then we lost "touch effect" when touching it. Could this behavior be changed in future releases?

Thanks in advance.  :)
« Last Edit: May 14, 2015, 02:32:54 pm by LoneVoice »

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: Android Module Wizard
« Reply #407 on: May 14, 2015, 05:51:39 pm »
Hi LoneVoice,

1.
Quote
...Is there a way to get position and size of a component? Right now Left/Top/Width/Height .

I will try later....

2.
Quote
...add component to form/custom dialog using code but failed

I will try later....

3.
Quote
...change color of a button, but then we lost "touch effect" when touching it

Solution:

Put a jPanel and  change its Backgroundcolor,  then configure [after put the button over it!]:
     
      LayoutParamWidth = lpWrapContent
      LayoutParamHeight = lpWrapContent

Now put a jButton over jPanel and configure:

      BackgroundColor = colbrDefault
      LayoutParamWidth = some value
      LayoutParamHeight = lpWrapContent
      PosRelativeToParent = [rpCenterInParent]
 
Thank you!
« Last Edit: May 14, 2015, 06:01:32 pm by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

LoneVoice

  • Newbie
  • Posts: 2
Re: Android Module Wizard
« Reply #408 on: May 14, 2015, 06:17:24 pm »
Hi jmpessoa,

Solution:

Put a jPanel and  change its Backgroundcolor,  then configure [after put the button over it!]:
     
      LayoutParamWidth = lpWrapContent
      LayoutParamHeight = lpWrapContent

Now put a jButton over jPanel and configure:

      BackgroundColor = colbrDefault
      LayoutParamWidth = some value
      LayoutParamHeight = lpWrapContent
      PosRelativeToParent = [rpCenterInParent]

Ops I forgot button itself is transparent by default so we just need to change color of component behind it, thanks!

A.S.

  • Jr. Member
  • **
  • Posts: 76
Re: Android Module Wizard
« Reply #409 on: May 14, 2015, 09:06:22 pm »
greenzyzyzy, try to update .java files.

greenzyzyzy

  • Full Member
  • ***
  • Posts: 249
Re: Android Module Wizard
« Reply #410 on: May 15, 2015, 05:19:59 am »
greenzyzyzy, try to update .java files.

i have change to jdk 1.8.20,problem still not solved.

m4u_hoahoctro

  • Full Member
  • ***
  • Posts: 160
Re: Android Module Wizard
« Reply #411 on: May 15, 2015, 05:29:51 am »
about my problem ?

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: Android Module Wizard
« Reply #412 on: May 15, 2015, 05:40:44 am »
@ greenzyzyzy

Quote
greenzyzyzy, try to update .java files.

Just about:

Lazarus IDE -->> Tools --> [Lamw] Android Module Wizard -->> Upgrade Code Templates [*.lpr, *.java]

@m4u_hoahoctro,

Ok I will try some solution!

Thanks to All!


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

greenzyzyzy

  • Full Member
  • ***
  • Posts: 249
Re: Android Module Wizard
« Reply #413 on: May 15, 2015, 11:29:15 am »
@ greenzyzyzy

Quote
greenzyzyzy, try to update .java files.

Just about:

Lazarus IDE -->> Tools --> [Lamw] Android Module Wizard -->> Upgrade Code Templates [*.lpr, *.java]

@m4u_hoahoctro,

Ok I will try some solution!


i have tested,problem still exist.
Thanks to All!

i have tested,problem still exist.and i build apk file,always need build two times,first failed,second
ok.is this case the probolem?(build step is ide->run->build apk and run.)
« Last Edit: May 15, 2015, 11:35:04 am by greenzyzyzy »

A.S.

  • Jr. Member
  • **
  • Posts: 76
Re: Android Module Wizard
« Reply #414 on: May 15, 2015, 08:50:01 pm »
greenzyzyzy, can you provide build log (copy from messages window)?

greenzyzyzy

  • Full Member
  • ***
  • Posts: 249
Re: Android Module Wizard
« Reply #415 on: May 16, 2015, 04:29:56 am »
greenzyzyzy, can you provide build log (copy from messages window)?

first time build apk show error:

BUILD FAILED
E:\lazarusandroid\android-sdk\tools\ant\build.xml:720: The following error occurred while executing this line:
E:\lazarusandroid\android-sdk\tools\ant\build.xml:734: Compile failed; see the compiler error output for details.


second time build apk ok.

greenzyzyzy

  • Full Member
  • ***
  • Posts: 249
Re: Android Module Wizard
« Reply #416 on: May 16, 2015, 04:32:38 am »
greenzyzyzy, can you provide build log (copy from messages window)?

another question.laz4android play a mp3 need what uses-permission?
see topice here:
http://forum.lazarus.freepascal.org/index.php/topic,28445.0.html

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: Android Module Wizard
« Reply #417 on: May 16, 2015, 04:54:20 am »
@greenzyzyzy

Quote
...laz4android play a mp3 need what uses-permission?

no special .... but if your file is in the sdcard you will need:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

NOTE: Lamw has jMediaPlayer component e a demo "AppTryCode2":

Code? just try:

Code: [Select]
     jMediaPlayer1.SetDataSource('pipershut2.mp3');  //from  .../assets...
     jMediaPlayer1.Prepare();
     jMediaPlayer1.Start();

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

greenzyzyzy

  • Full Member
  • ***
  • Posts: 249
Re: Android Module Wizard
« Reply #418 on: May 16, 2015, 05:12:27 am »
@greenzyzyzy

Quote
...laz4android play a mp3 need what uses-permission?

no special .... but if your file is in the sdcard you will need:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

NOTE: Lamw has jMediaPlayer component e a demo "AppTryCode2":

Code? just try:

Code: [Select]
     jMediaPlayer1.SetDataSource('pipershut2.mp3');  //from  .../assets...
     jMediaPlayer1.Prepare();
     jMediaPlayer1.Start();

Thank you!

i have add the permission,it seems still can not run.



code put here:


Code: [Select]
unit mediaplayer;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils,jni,customdrawnint;
var
  jmediaplayer_class:jclass;
  jmediaplayer_jobject:jobject;
  create_id:jmethodid;
  setdatasource_id:jmethodid;
  prepare_id:jmethodid;
  start_id:jmethodid;
  release_id:jmethodid;
procedure media_create();
procedure SetDataSource(path: string);
procedure Prepare();
procedure Start();
procedure Release();


implementation
procedure media_create();
begin
 jmediaplayer_class:=javaEnvRef^^.FindClass(javaEnvRef,'android/media/MediaPlayer');

 create_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, '<init>', '()V');
 setdatasource_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, 'SetDataSource', '(Ljava/lang/String;)V');
 prepare_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, 'Prepare', '()V');
 start_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, 'Start', '()V');
 release_id:= javaEnvRef^^.GetMethodID(javaEnvRef, jmediaplayer_class, 'Release', '()V');

 jmediaplayer_jobject:=javaEnvRef^^.NewObject(javaEnvRef,jmediaplayer_class,create_id);

end;


procedure SetDataSource(path: string);
var
  lParams: array[0..0] of jValue;
begin
 lParams[0].l := javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(path));
 javaEnvRef^^.CallVoidMethodA(javaEnvRef, jmediaplayer_jobject,setdatasource_id, @lParams[0]);
 javaEnvRef^^.DeleteLocalRef(javaEnvRef, lParams[0].l);

end;

procedure Prepare();
begin
 javaEnvRef^^.CallVoidMethod(javaEnvRef, jmediaplayer_jobject,prepare_id);
end;

procedure Start();
begin
 javaEnvRef^^.CallVoidMethod(javaEnvRef, jmediaplayer_jobject,start_id);
end;

procedure Release();
begin
 javaEnvRef^^.CallVoidMethod(javaEnvRef, jmediaplayer_jobject,release_id);
end;

end.
 
« Last Edit: May 16, 2015, 05:15:34 am by greenzyzyzy »

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: Android Module Wizard
« Reply #419 on: May 16, 2015, 05:40:22 am »
@greenzyzyzy,

You need know/discovery what is the path to your device sdcard ...  just "/sdcard" can not work for all devices .... in java: Environment.getExternalStorageDirectory()
« Last Edit: May 16, 2015, 05:49:08 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

 

TinyPortal © 2005-2018