Category: StackOverflow

Error on compiling Firemonkey Android APP

What is wrong with this code? Delphi 10.4 Compiler gives me Not enough actual parameters Error is on: ServiceConnection.onServiceConnected := OnServiceConnected; and ServiceConnection.onServiceConnected := OnServiceConnected; Here is the code: unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, Androidapi.JNI.GraphicsContentViewText, Androidapi.JNI.JavaTypes, Androidapi.Helpers, Androidapi.JNIBridge, Androidapi.JNI.App, Androidapi.JNI.Os, FMX.Platform.Android, FMX.Controls.Presentation, FMX.StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private procedure OnServiceConnected(name: JComponentName; Binder: JIBinder); procedure OnServiceDisconnected(name: JComponentName); { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.fmx} procedure TForm1.OnServiceConnected(name: JComponentName; Binder: JIBinder); begin // end; procedure TForm1.OnServiceDisconnected(name: JComponentName); begin // end; procedure TForm1.Button1Click(Sender: TObject); var Intent: JIntent; ServiceConnection: JServiceConnection; begin Intent := TJIntent.Create; Intent.setPackage(StringtoJString('com.xxx.xxxservice')); Intent.setAction(StringtoJString('com.xxx.xxxservice')); ServiceConnection := TJServiceConnection.Create; ServiceConnection.onServiceConnected := OnServiceConnected; // Not enough actual parameters !!! ServiceConnection.onServiceDisconnected := OnServiceDisconnected; // Not enough actual parameters !!! TAndroidHelper.Context.bindService(Intent, ServiceConnection, TJContext.JavaClass.BIND_AUTO_CREATE); end; end.
Read More

Delphi 10.3 Android Remote Service crash when binding

I tried to build an APP with a remote service, and the service will communicate to other APP that I would like to check it still running. I reference the FMX.Remote Service Demo Sample create a Multi-Device project and a Android Remote Service project, and add some code to create RemoteServiceConnection and call BindService procedure. But APP crash when it call BindService, then I tried to build Sample but also crash when I press Bind button. I build the Sample on Mi Pad 4, Oppo R9sk, HUAWEI MediaPad M5 lite, and Mi 6, are all the same result, and Mi 6 report the message: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.embarcadero.AppRemoteHost-EOCjVTj9dNHejm_JDi44nw==/base.apk"], nativeLibraryDirectories=[/data/app/com/embarcadero.AppRemoteHost-EOCjVT9dNHejm_JDi44nw==/lib/arm, /data/app/com.embarcadero.AppRemoteHost-EOCjVTj9dNHejm_JDi44nw==/base.apk!/lib/armeabi-v7a, /system/lib, /system/vendor/lib]]] couldn't find "libProxyAndroidService.so" at at java.lang.Runtime.loadLirary0(Runtime.java:1012) at java.land.System.loadLibrary(System.java:1669) Anyone can help?
Read More

Virtual Keyboard does not appear for TFloatColumn editor of FMX.Grid.TStringGrid on popup form in FireMonkey Android app

The main form of my FireMonkey application includes a TStringGrid with a TFloatColumn for entering values and a TGylph column for implementing a "button". When I detect the "button" being clicked I show a new form, non-modal of course, which also contains a TStringGrid with a TFloatColumn for entering values. The problem I'm having is that clicking on the cell for the TFLoatColumn of the main form opens the virtual keyboard, but clicking on the cell for the TFloatColumn of the popup form does not. Both grids have identical settings (apart from the name) and the TFloatColumns also have identical settings, so why doesn't the virtual keyboard appear?
Read More

Turn off Virtual Keyboard for one control in FireMonkey Android app

What's the best way to turn off the virtual keyboard for a particular FMX.Edit.TEdit control? Is it to use VKAutoShowMode := TVKAutoShowMode.Never; in the OnEnter event and VKAutoShowMode := TVKAutoShowMode.DefinedBySystem; in the OnExit event? I'm not entirely happy with this approach, as if something doesn't go according to plan, the virtual keyboard is hidden for every control in the app. Or just use Keyboard.HideVirtualKeyboard; in the OnEnter event? This sort of works, but if you click into the control a second time, the keyboard appears. I can see the control has a KeyboardType property, but None is not one of the available choices. Am I missing something here? EDIT: I cannot set ReadOnly to true, as it is being used for capturing the text from a barcode scanner. EDIT: Since VKAutoShowMode := TVKAutoShowMode.Never; works the majority of the time I'll just continue to use that method, but add extra event handlers to use VKAutoShowMode := TVKAutoShowMode.DefinedBySystem; when other edit controls get the focus.
Read More

How to make Firemonkey TWebBrowser load over fifty photos in one html file [closed]

I have an html file containing over 50 photos, each in an <img> tag. The file is correctly showing in Microsoft Edge as well as in Google Chrome. However, in FireMonkey TWebBrowser, only about 30 photos can be seen. Others just show the "alt" text. Is there anyway to improve this so all photo files can be seen? Please note, in Delphi 10.3, there are two different controls both in the name of TWebBrowser. The one I am using is the FireMonkey TWebBrowser. My test page is too large (with 100 hundred photos each in an img tag) to present here. I also tried it in Delphi 10.4 which is just released two months ago. But the result was the same: not all photos can be seen.
Read More

Strange characters in Listview

I have this code for an Android project for autoheight the Listview Text. Everything works fine with fix height. When I activate this code LText.Height := ListView1.getItemTextHeight(LText)+10; the autoheight works fine but came with that strange characters on Bold and some times a “Duplicates not allowed” error message.
In Windows works fine but on Android I have this.

    for i := 0 to FDMemTable1.RecordCount -1 do
      begin
        UName := (FDMemTable1.FieldByName('username').Value);
        Descr := (FDMemTable1.FieldByName('descr').Value);
        Ext := (FDMemTable1.FieldByName('ext').Value);
        Url := (FDMemTable1.FieldByName('vurl').Value);
        FCanUpdate := False;
        LItem := ListView1.Items.Add;
        LItem.Data['UName'] := UName;
        LItem.Data['Descr'] := Descr;
        LItem.Data['Ext'] := Ext;
        LItem.Data['Url'] := Url;
        FCanUpdate := True;
        LItem.Adapter.ResetView(LItem);
        FDMemTable1.Next;
      end;
    ListView1.EndUpdate;
end;

procedure TForm7.ListView1UpdatingObjects(const Sender: TObject;
  const AItem: TListViewItem; var AHandled: Boolean);
var
  h: integer;
  LText: TListItemText;
begin
  h := 2;
  LText := AItem.Objects.FindObjectT<TListItemText>('UName_text');
  if LText = nil then
    begin
      LText := TListItemText.Create(AItem);
      LText.Name := 'UName_text';
      LText.PlaceOffset.X := 18;
      LText.PlaceOffset.Y := h;
      LText.TextColor := TAlphaColorRec.Black;
      LText.TextAlign := TTextAlign.Leading;
      LText.TextVertAlign := TTextAlign.Leading;
      LText.Font.Size := 14;
      LText.Font.Style := [TFontStyle.fsBold];
    end;
  LText.Width := (Sender as TListView).Width - 18;
  LText.Text := AItem.Data['UName'].AsString;
  LText.Height := 22;
  h := Round(h + LText.Height +7);

  if AItem.Data['Descr'].AsString <> '' then
  begin
    LText := AItem.Objects.FindObjectT<TListItemText>('Descr_text');
    if LText = nil then
      begin
        LText := TListItemText.Create(AItem);
        LText.Name := 'Descr_text';
        LText.PlaceOffset.X := 18;
        LText.PlaceOffset.Y := h;
        LText.TextColor := TAlphaColorRec.Black;
        LText.TextAlign := TTextAlign.Leading;
        LText.TextVertAlign := TTextAlign.Leading;
        LText.WordWrap := True;
        LText.Font.Size := 13;
        LText.Font.Style := [];
      end;
    LText.Width := (Sender as TListView).Width - 20;
    LText.Text := AItem.Data['Descr'].AsString;

//    LText.Height := ListView1.getItemTextHeight(LText)+10;

    LText.Height := 30;

    h := Round(h + LText.Height + 5);
  end;
  AItem.Height := h;
  AHandled := True;
end;

The screenshot from my phone.

What goes wrong with this ???

Read More

Read More

Added TButton won’t align with previous TButtons after upgrade from 10.3.1 to 10.3.3 in Android

I'm using FireMonkey to create my Android application. I have 6 TButtons on a panel and want to insert a 7th. The 6 were positioned under CX 10.3.1 on an android device. I recently upgraded to CX 10.3.3, and wanted to insert a 7th TButton in that row -- there is room -- but the installed result on the android device has an older button and the new one stepping on each other. I then tried to take the end (old) TButton and place it below the row of 6 and put the new TButton where the old one was and align the row using Space equally and I still get a mess. Has there been a change in buttons? The new button is from the Standard Palette. It has been a while since I wrote the original code, but was there a FireMonkey based TButton before that I should be using? And if so, where is it located? Any help would sure be appreciated.
Read More

Target Android API 29 on Delphi 10.3.3

I have the Delphi 10.3.3, and I have some apps on Google Play that I update frequently. The case is that on Nov 2, I will have to target API 29 on my apps. The thing is that Delphi 10.3.3 does not do this automatically. So this is the list of things I think I have to do and I do not know how to do them: Download the new API 29 with the Android SDK Manager of the Delphi (which I don't find) Edit the SDK Manager configuration to install well the API 29 Edit the Android Manifest file to target API 29 The case is that I do not know how to edit the AndroidManifest file through Delphi because I think I need to do some steps before. (I need to know how to edit it, I do not find this info anywhere) I need to install the API 29, configure it well on Delphi, and edit AndroidManifest.xml in Delphi. I'll appreciate your answers. I need help :-)
Read More

Firemonkey FMX.Android Intents not working properly when using chrome

I have followed the steps in this link to create a sample Firemonkey app that receives an intent. The app works fine with all applications but Chrome. Most of the time, Chrome seems to create a “second instance” of the application as you can see in the following screenshot:

In the left side is the main app and in the right side is Chrome after selecting “Share” and selecting the app from the list of available apps that can receive the intent. As you can see in the picture, Chrome is somehow displaying the icon of the app inside of itself and remains unresponsive. With all other apps, usually the app is shown as the active app (foreground) and displays the data it received but with Chrome, 95% of the time, I have this issue. Is there any reason why this is happening only with Chrome?

Read More

Read More

Slow performance of TGrid everytime it is created at runtime through dynamic (increasing data) TFDMemTable definition provided REST API data

I am developing Firemonkey App for iOS and Android. I noticed that the app gets slower performance in iOS and Android debugging everytime the TGrid is created at runtime using the TFDMemTable REST API data and structure. I already applied the FreeAndNil(TGrid1); to cleanup TGrid before it creates over and over again. One notable event, everytime the TGrid is created the rows are increasing with fixed 7 columns the performance gets slower. Normally, this happens when I reached to 10 rows or records. My one big and real quick question: Where do you think the overheads are coming from that caused the performance to slow? TGrid — which I already applied FreeAndNil(TGrid1); before its creation. TFMemTable — I haven't checked this and I do not know how TButton — the one that triggers the creation and loading of data to TGrid. Most of the codes reside here Let's assume that all other components are working fine prior to this case. I could share to you some code if you want to but guide me which one you want to see. UPDATE 1 : MINIMUM REPRODUCIBLE EXAMPLE FMX File object Form9: TForm9 Left = 0 Top = 0 Caption = 'MRE TeeGrid Runtime'#13#10 ClientHeight = 480 ClientWidth = 294 FormFactor.Width = 320 FormFactor.Height = 480 FormFactor.Devices = [Desktop] DesignerMasterStyle = 0 object btn1: TButton Align = Bottom Position.Y = 440.000000000000000000 Size.Width = 294.000000000000000000 Size.Height = 40.000000000000000000 Size.PlatformDefault = False TabOrder = 9 Text = 'CREATE TEEGRID' OnClick = btn1Click end object aniSearchProcess: TAniIndicator Position.X = 128.000000000000000000 Position.Y = 216.000000000000000000 end object lyt1: TLayout Align = Client Size.Width = 294.000000000000000000 Size.Height = 440.000000000000000000 Size.PlatformDefault = False TabOrder = 11 end object cur1: TFDGUIxWaitCursor Provider = 'FMX' Left = 32 Top = 32 end object dvr1: TFDPhysSQLiteDriverLink Left = 88 Top = 32 end object con1: TFDConnection Params.Strings = ( 'DriverID=SQLite') Connected = True LoginPrompt = False Left = 144 Top = 32 end object loc1: TFDLocalSQL Connection = con1 Active = True Left = 200 Top = 32 end object rsc1: TRESTClient Accept = 'application/json, text/plain; q=0.9, text/html;q=0.8,' AcceptCharset = 'utf-8, *;q=0.8' BaseURL = 'https://me6hwinr2k.execute-api.ap-southeast-1.amazonaws.com/v0/d' + 'bqueries?item-var=9&qty=25' Params = <> Left = 32 Top = 112 end object rsq1: TRESTRequest Client = rsc1 Params = <> Response = rsp1 SynchronizedEvents = False Left = 32 Top = 176 end object rsp1: TRESTResponse ContentType = 'application/json' Left = 32 Top = 240 end object rsd1: TRESTResponseDataSetAdapter Active = True Dataset = mtb1 FieldDefs = <> Response = rsp1 Left = 32 Top = 304 end object mtb1: TFDMemTable Active = True FieldDefs = < item Name = 'Category' DataType = ftWideString Size = 255 end item Name = 'ID' DataType = ftWideString Size = 255 end item Name = 'Item' DataType = ftWideString Size = 255 end item Name = 'Qty' DataType = ftWideString Size = 255 end item Name = 'Container' DataType = ftWideString Size = 255 end item Name = 'Size' DataType = ftWideString Size = 255 end item Name = 'Ex temporibus dolore consequatur.' DataType = ftWideString Size = 255 end item Name = 'Et cum aut est nostrum...' DataType = ftWideString Size = 255 end item Name = 'Sequi quibusdam eum.' DataType = ftWideString Size = 255 end> IndexDefs = <> FetchOptions.AssignedValues = [evMode] FetchOptions.Mode = fmAll ResourceOptions.AssignedValues = [rvSilentMode] ResourceOptions.SilentMode = True UpdateOptions.AssignedValues = [uvCheckRequired, uvAutoCommitUpdates] UpdateOptions.CheckRequired = False UpdateOptions.AutoCommitUpdates = True StoreDefs = True Left = 32 Top = 368 end end FMX Procedures unit Main; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FireDAC.UI.Intf, FireDAC.FMXUI.Wait, FireDAC.Stan.ExprFuncs, FireDAC.Phys.SQLiteDef, FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Error, FireDAC.Phys.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.SQLite, Data.DB, FireDAC.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf, REST.Types, FMX.Controls.Presentation, FMX.StdCtrls, FireDAC.Comp.DataSet, FireDAC.Comp.Client, REST.Response.Adapter, REST.Client, Data.Bind.Components, Data.Bind.ObjectScope, FireDAC.Phys.SQLiteVDataSet, FireDAC.Comp.UI, FMXTee.Control, FMXTee.Grid, FMX.Layouts; type TForm9 = class(TForm) cur1: TFDGUIxWaitCursor; dvr1: TFDPhysSQLiteDriverLink; con1: TFDConnection; loc1: TFDLocalSQL; rsc1: TRESTClient; rsq1: TRESTRequest; rsp1: TRESTResponse; rsd1: TRESTResponseDataSetAdapter; mtb1: TFDMemTable; btn1: TButton; aniSearchProcess: TAniIndicator; lyt1: TLayout; procedure btn1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form9: TForm9; tgd1: TTeeGrid; implementation {$R *.fmx} procedure TForm9.btn1Click(Sender: TObject); var i, CanvassItemId, e : Integer; begin aniSearchProcess.Visible := True; aniSearchProcess.Enabled := True; {$IFDEF MSWINDOWS} Application.ProcessMessages; {$ENDIF} {$IF DEFINED(iOS) or DEFINED(ANDROID)} Application.HandleMessage; {$ENDIF} FreeAndNil(tgd1); //free old grid //create new grid tgd1 := TTeeGrid.Create(lyt1); With tgd1 do begin Parent := lyt1; Align := TAlignLayout.Client; Margins.Top := 5; Margins.Left := 5; Margins.Right := 5; Margins.Bottom := 5; ScrollBars.Visible := True; Header.Format.Font.Size := 11; Cells.Format.Font.Size := 11; TabOrder := 0; ScrollBars.Visible := False; end; con1.StartTransaction; try //define the API here for duplicate/update, initial click and subsequent clicks rsc1.BaseURL := 'https://0rgvn0s0gk.execute-api.ap-southeast-1.amazonaws.com/v0/dbqueries?item-var=1&qty=10'; rsq1.Execute; rsd1.Active := True; mtb1.Active; tgd1.DataSource := mtb1; tgd1.Enabled := True; // adjust the column properties dynamically with tgd1 do begin for i := 0 to Columns.Count -1 do begin if i = 0 then begin Columns[i].Visible := False; // category column end else if (i = 1) then begin Columns[i].Visible := False; // id column end else if (i = 2) then begin Columns[i].Width.Value := 120; // item column end else if (i = 3) then begin Columns[i].Width.Value := 30; // qty column end else if (i = 4) then begin Columns[i].Width.Value := 50; // container column end else if (i = 5) then begin Columns[i].Width.Value := 50; // size column end else begin Columns[i].Width.Value := 50; // subsequent random columns end; end; end; finally con1.Commit; end; aniSearchProcess.Visible := False; aniSearchProcess.Enabled := False; {$IFDEF MSWINDOWS} Application.ProcessMessages; {$ENDIF} {$IF DEFINED(iOS) or DEFINED(ANDROID)} Application.HandleMessage; {$ENDIF} end; end.
Read More

C++ Builder: How to set the height of a ProgressBar

It seems to be a simple task to do in C++ Builder, but it doesn't work. I have an application in Android and I tried to set the height of progressBar, e.g: ProgressBar1->Height = 30; But it keeps coming back to value = 10 (which is the standard value), so I can't put other value than 10. Is this a bug or something is missing to it works on Android? PS: If the application is for Windows, it works.
Read More