Category: StackOverflow

Why uploaded photo is much smaller than saved – Delphi 10.3.2, firemonkey

I have Delphi 10.3.2 I do not understand this situations: 1) Uploading photo about 1M image1.Bitmap.LoadFromFile('test.jpg'); Then I save the same photo image1.Bitmap.SaveToFile('test_new.jpg'); and test_new.jpg is about 3M. Why ??? 2) I want to send a photo from the TImage (test1.jpg - 1MB) object using IdHTTP and POST request to server. I use the function Base64_Encoding_stream to encode image. Image size (string) after encoding the function is 20 MB! ? Why if the original file has 1MB ? function Base64_Encoding_stream(_image:Timage): string; var base64: TIdEncoderMIME; output: string; stream_image : TStream; begin try begin base64 := TIdEncoderMIME.Create(nil); stream_image := TMemoryStream.Create; _image.Bitmap.SaveToStream(stream_image); stream_image.Position := 0; output := TIdEncoderMIME.EncodeStream(stream_image); stream_image.Free; base64.Free; if not(output = '') then begin Result := output; end else begin Result := 'Error'; end; end; except begin Result := 'Error' end; end; end; .... img_encoded := Base64_Encoding_stream(Image1); ..... procedure Send(_json:String ); var lHTTP : TIdHTTP; PostData : TStringList; begin PostData := TStringList.Create; lHTTP := TIdHTTP.Create(nil); try PostData.Add('dane=' + _json ); lHTTP.Request.UserAgent := 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0'; lHTTP.Request.Connection := 'keep-alive'; lHTTP.Request.ContentType := 'application/x-www-form-urlencoded'; lHTTP.Request.Charset := 'utf-8'; lHTTP.Request.Method := 'POST'; _dane := lHTTP.Post('http://......./add_photo.php',PostData); finally lHTTP.Free; PostData.Free; end;
Read More

FMX Android TControl.MakeScreenShot or TCanvas.FillText always generate black block around fonts

I want to create a picture with "white background and black labels" and share it using intent. But my picture always generate black block around all fonts. It's been 2 days now I'm stuck on this problems. Anybody has solution or can point me to the right direction? or any workaround if it's still a bug from developer? I'm using 10.2 Thank you. Edit: Adding example Code unit UTest; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls, FMX.Objects, FMX.Controls.Presentation; type TFTest = class(TForm) Rectangle1: TRectangle; Label1: TLabel; Label2: TLabel; Label3: TLabel; Image1: TImage; Button1: TButton; Button2: TButton; Image2: TImage; Button3: TButton; Button4: TButton; procedure Button1Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button4Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var FTest: TFTest; implementation {$R *.fmx} Uses System.IOUtils; procedure TFTest.Button1Click(Sender: TObject); begin Image2.Bitmap := Rectangle1.MakeScreenshot; end; procedure TFTest.Button2Click(Sender: TObject); var mrect:trect; begin Image1.Bitmap.SetSize(Trunc(Image1.Width * Image1.Canvas.Scale), Trunc(Image1.Height * Image1.Canvas.Scale)); Image1.bitmap.Canvas.BeginScene; Image1.Bitmap.canvas.Clear(TAlphaColors.White); Image1.bitmap.Canvas.Stroke.Thickness := 1; Image1.bitmap.Canvas.Stroke.Color := TAlphaColorRec.Black; Image1.Bitmap.canvas.Stroke.Kind := TBrushKind.bkSolid; Image1.bitmap.Canvas.Fill.Color := TAlphaColors.Black; Image1.Bitmap.Canvas.Fill.DefaultColor:=TAlphaColors.White; Image1.Bitmap.Canvas.Font.Size:=10; Image1.Bitmap.Canvas.Font.Family:='Arial'; Image1.Bitmap.Canvas.Font.Style:=[TFontStyle.fsbold]; Image1.bitmap.canvas.Blending:=false; Image1.Bitmap.Canvas.DrawLine(PointF(20, 10), PointF(330, 10), 1); mRect.Create(20, 10, 180, 30); Image1.bitmap.Canvas.filltext(mRect, 'DD:MM:YY HH:MM', false, 0, [],TTextAlign.Leading, TTextAlign.Center); mRect.Create(180, 10, 330, 30); Image1.bitmap.Canvas.filltext(mRect, 'SHID/CNAME', false, 1, [],TTextAlign.Trailing, TTextAlign.Center); Image1.Bitmap.Canvas.DrawLine(PointF(20, 30), PointF(330, 30), 1); Image1.bitmap.Canvas.EndScene; {$IFDEF ANDROID} image1.bitmap.SaveToFile(TPath.GetHomePath() + TPath.DirectorySeparatorChar + 'screenshot.jpg'); image2.Bitmap.LoadFromFile(TPath.GetHomePath() + TPath.DirectorySeparatorChar + 'screenshot.jpg'); {$ENDIF} {$IFDEF MSWINDOWS} image1.Bitmap.SaveToFile('E:\screenshot.jpg'); image2.Bitmap.LoadFromFile('E:\screenshot.jpg'); {$ENDIF} end; procedure TFTest.Button3Click(Sender: TObject); var bmp: TBitmap; begin bmp := TBitmap.Create; bmp.Width := Image2.bitmap.Width; bmp.Height := Image2.bitmap.Height; bmp := Rectangle1.MakeScreenshot; {$IFDEF ANDROID} bmp.SaveToFile(TPath.GetHomePath() + TPath.DirectorySeparatorChar + 'screenshot.jpg'); image2.Bitmap.LoadFromFile(TPath.GetHomePath() + TPath.DirectorySeparatorChar + 'screenshot.jpg'); {$ENDIF} {$IFDEF MSWINDOWS} bmp.SaveToFile('E:\screenshot.jpg'); image2.Bitmap.LoadFromFile('E:\screenshot.jpg'); {$ENDIF} end; procedure TFTest.Button4Click(Sender: TObject); begin image1.Bitmap := nil; image2.Bitmap := nil; end; end. Form object FTest: TFTest Left = 0 Top = 0 Caption = 'Form1' ClientHeight = 530 ClientWidth = 360 FormFactor.Width = 320 FormFactor.Height = 480 FormFactor.Devices = [Desktop] DesignerMasterStyle = 3 object Rectangle1: TRectangle Fill.Color = claWhite Position.X = 8.000000000000000000 Position.Y = 8.000000000000000000 Size.Width = 345.000000000000000000 Size.Height = 121.000000000000000000 Size.PlatformDefault = False Stroke.Kind = None object Label1: TLabel Align = Top Size.Width = 345.000000000000000000 Size.Height = 23.000000000000000000 Size.PlatformDefault = False TextSettings.HorzAlign = Center Text = 'Label1' TabOrder = 0 end object Label2: TLabel Position.X = 23.000000000000000000 Position.Y = 80.000000000000000000 Text = 'Label2' TabOrder = 1 end object Label3: TLabel Position.X = 23.000000000000000000 Position.Y = 48.000000000000000000 Text = 'Label3' TabOrder = 2 end end object Image1: TImage MultiResBitmap = Position.X = 8.000000000000000000 Position.Y = 136.000000000000000000 Size.Width = 345.000000000000000000 Size.Height = 121.000000000000000000 Size.PlatformDefault = False end object Button1: TButton Position.X = 8.000000000000000000 Position.Y = 264.000000000000000000 Size.Width = 345.000000000000000000 Size.Height = 44.000000000000000000 Size.PlatformDefault = False TabOrder = 2 Text = 'TLayout.MakeScreenShot (No Saving)' OnClick = Button1Click end object Button2: TButton Position.X = 8.000000000000000000 Position.Y = 360.000000000000000000 Size.Width = 193.000000000000000000 Size.Height = 44.000000000000000000 Size.PlatformDefault = False TabOrder = 3 Text = 'TCanvas.FillRect' OnClick = Button2Click end object Image2: TImage MultiResBitmap = Position.X = 8.000000000000000000 Position.Y = 408.000000000000000000 Size.Width = 345.000000000000000000 Size.Height = 121.000000000000000000 Size.PlatformDefault = False end object Button3: TButton Position.X = 8.000000000000000000 Position.Y = 312.000000000000000000 Size.Width = 345.000000000000000000 Size.Height = 44.000000000000000000 Size.PlatformDefault = False TabOrder = 5 Text = 'TLayout.MakeScreenShot (Saving)' OnClick = Button3Click end object Button4: TButton Position.X = 208.000000000000000000 Position.Y = 360.000000000000000000 Size.Width = 137.000000000000000000 Size.Height = 44.000000000000000000 Size.PlatformDefault = False TabOrder = 6 Text = 'Image NIL' OnClick = Button4Click end end On windows everything is normal, but when i run it on android: TLayout MakeScreenShot without saving has gray block around fonts. TLayout MakeScreenShot with saving has black block around fonts. TCanvas FillRect has black block around fonts. Canvas FillText
Read More

Problem displaying items in Listbox and Memo in Firemonkey Android application

I am at my first experiences with Android development using Delphi/Firemonkey 10.3.1 and have encountered the following problem with populating and displaying items in a TListbox component and a TMenu component at run time. I have placed TListbox and TMenu components on a panel, together with a button to trigger the generation of a sequence of random numbers and display them in these components. The TListbox component contains objects of class TListboxItemRandomNo descending from TListboxItem. The code for this class is: TListboxItemRandomNo= class(TListboxItem) private FRandomNo: integer; {Number displayed by Listbox item} protected procedure HandlePaint(Sender: TObject; Canvas: TCanvas; const ARect: TRectF); function GetItemText: string; public constructor Create(Owner: TComponent; RandomNoValue: integer); property RandomNo: integer read FRandomNo; end; constructor TListboxItemRandomNo.Create(Owner: TComponent; RandomNoValue: integer); var Listbox: TListbox; begin Listbox:= Owner as TListbox; inherited Create(Owner); Listbox.AddObject(Self); {Save RandonNo:} FRandomNo:= RandomNoValue; {Assign OnPaint event handler:} OnPaint:= HandlePaint; end; procedure TListboxItemRandomNo.HandlePaint(Sender: TObject; Canvas: TCanvas; const ARect: TRectF); var Text: string; TextSize: TSizeF; TextPosn: TPointF; TextRect: TRectF; begin {Calculate item text:} Text:= GetItemText; {Set colour for text:} Canvas.Fill.Color:= TAlphaColorRec.Black; {Determine text image size, position and bounding rectangle:} TextSize.cx:= Canvas.TextWidth(Text); TextSize.cy:= Canvas.TextHeight(Text); TextPosn.x:= ARect.Left + 5; TextPosn.y:= (ARect.Top + ARect.Bottom - TextSize.cy)/2; TextRect.TopLeft:= TextPosn; TextRect.Right:= ARect.Right; TextRect.Bottom:= TextRect.Top + TextSize.cy; {Draw item text:} Canvas.FillText(TextRect, Text, False, 1.0, [], TTextAlign.Leading, TTextAlign.Center); end; function TListboxItemRandomNo.GetItemText: string; begin Result:= IntToStr(Index) + ': ' + IntToStr(FRandomNo); end; Initially I put the code to generate and display the random numbers in the OnClick event handler of the button. Whilst this approach worked on the Windows 32-bit platform, on the Android platform in both the TListbox and the TMemo components the items were not displayed. I then created an Action called ActionCalcRandomNos and moved the code to generate and display the random numbers from the button’s OnClick event handler into the OnExecute event handler of the action. I disconnected the OnClick event handler of the button and assigned ActionCalcRandomNos to it instead. After these changes I found that the items in both the TListbox and the TMemo components were displayed on both the Windows-32 and the Android platforms. The code in question is: procedure TForm1.ActionCalcRandomNosExecute(Sender: TObject); {Calculates a random sequence of numbers and displays them in TListbox and TMemo components} var i: integer; xi: integer; ListboxItemRandomNo: TListboxItemRandomNo; LineI: string; begin {Read number of random numbers required:} FRandomNoCount:= StrToInt(EditItemCount.Text); SetLength(FRandomNoSequence, FRandomNoCount); {Generate random number sequence:} Randomize; for i := 0 to FRandomNoCount-1 do begin xi:= Random(FRandomNoCount); FRandomNoSequence[i]:= xi; end; {Generate Listbox items dislaying random numbers:} ListBoxRandomSequence.Clear; ListBoxRandomSequence.BeginUpdate; for i:= 0 to FRandomNoCount-1 do begin ListboxItemRandomNo:= TListboxItemRandomNo.Create(ListBoxRandomSequence, FRandomNoSequence[i]); end; ListBoxRandomSequence.EndUpdate; {Write random numbers to TMemo:} MemoRandomNos.Lines.Clear; MemoRandomNos.BeginUpdate; for i:= 0 to FRandomNoCount-1 do begin LineI:= (ListBoxRandomSequence.ListItems[i] as TListboxItemRandomNo).GetItemText; MemoRandomNos.Lines.Add(LineI); end; MemoRandomNos.EndUpdate; end; Why did this code not work when called directly from the button OnClick event handler, but did work when called indirectly via the action ActionCalcRandomNos connected to the button? The only remaining minor problem with the TListbox is this. The item height, which is set as 0 in the Object Inspector, on the Android platform version only is being displayed much too great. This started after I changed the ItemHeight property back to 0 after previously having set it at 20. Any light shed on any of these problems would be helpful.
Read More

Why isn’t InputQuery returning bool?

I've followed the clear documentation to implement an input dialog box. It works fine. But, now i want to ignore the user input if they click cancel. Below is quote from that documentation. "If the user clicks the OK button, InputQuery returns True; InputQuery returns False otherwise." So, i tried the following code and the error i'm getting is E2034 Cannot convert void to bool when i run on Win32 and bccaarm error 1711 value of type void is not contextually convertible to bool on Android. if (InputQuery(caption, Prompts, sizeof(Prompts)/sizeof(Prompts[0]) - 1, Defaults, sizeof(Defaults)/sizeof(Defaults[0]) - 1, (TInputCloseQueryProc *)Met)){ // clicked OK } else { // clicked cancel } How can i test if OK or Cancel clicked? Below is the declaration for InputQuery and it should be bool. I'm confused. extern DELPHI_PACKAGE bool __fastcall InputQuery _DEPRECATED_ATTRIBUTE1("Use FMX.DialogService methods") (const System::UnicodeString ACaption, const System::UnicodeString *APrompts, const int APrompts_High, System::UnicodeString *AValues, const int AValues_High, const _di_TInputCloseQueryFunc ACloseQueryFunc = _di_TInputCloseQueryFunc())/* overload */;
Read More

Using the GetClass function with VCL / FMX not found

I have the following situation, project in *.bpl VCL structure. I want to adapt a screen made in FMX in this structure using LoadPackage and GetClass.

When I run form VCL after running FMX it loses reference in the GetClass function. But it can return the address that was allocated in the LoadPackage function. I couldn’t see what might be going on.

If anyone has an idea of ​​what might be happening or has been through it.

Code:

In untFormFMX.pas

initialization
  RegisterClass(TForm1);

finalization
  UnRegisterClass(TForm1);

In VCLForms.pas

initialization
  RegisterClass(TForm2);

finalization
  UnRegisterClass(TForm2);

In untPrinc.pas

procedure OpenFMXForm;
var
  oFMXForm: TForm;
  oFMXClass: TPersistentClass;
begin
  LoadPackage('pctFMXForms.bpl');
  oFMXClass := GetClass('TForm1');
  Application.CreateForm(TFormClass(oFMXClass) ,oFMXForm );
  TForm(oFMXForm).ShowModal
end;

procedure OpenVCLForm;
var
  oVCLForm: TForm;
  oVCLClass: TPersistentClass;
begin
  LoadPackage('pctVCLForms.bpl');
  oVCLClass := GetClass('TForm2');
  Application.CreateForm(TFormClass(oVCLClass) ,oVCLForm );
  TForm(oVCLForm).ShowModal
end;

Process:

1° Open VCL Form: OK
2° Open FMX Form: OK
3° Open VCL Form: not found return nil

Read More

Read More

Hardware Locked Licensing Delphi RIO

i want my user to use my software only in one system or login once at a time for that i want to know how can i create such keys that's effected by changes in other hardware. I am using that key to check in server and return true if the key generated by user hardware is same as key stored at first login from my desktop app. and at logout i am deleting that key from server and saving the key which will be fetched from next login hardware.. I've read all the related question but they are useless when any part of hardware is changed(such as hdd changed). and i know that this thing is not 100%. Is key based on bios is good alternative to hdd cpu and other components as they may change anytime ? https://www.azsdk.com/hardwareid.html i found this for delphi but this is way back updated and supported in windows 7 don't know about Windows 10.
Read More

how to configure tls on Delphi TRestClient component

Helo, I typed the code as follows and this code works well. By using an https connection I hope that the Packet Data received cannot be read by applications such as Wireshark or the Packet Capture application on Android. how do you configure the client side? this my code procedure TForm1.Button1Click(Sender: TObject); var MyCompletionHandler: TCompletionHandler; MyErrorCompletionHandler: TCompletionHandlerWithError; begin ShowLoadingIndicator(Self, True); Memo1.Lines.Clear; RESTClient1.BaseURL := 'https://reqres.in/'; RESTClient1.RaiseExceptionOn500 := False; RESTClient1.SecureProtocols := [THTTPSecureProtocol.TLS12]; RESTRequest1.ClearBody; RESTRequest1.Resource := 'api/users'; MyCompletionHandler := procedure var i: Integer; tJson: TJSONValue; begin Label1.Text := 'Complete!'; Memo1.Lines.Append('Header: '); for I := 0 to RESTResponse1.Headers.Count-1 do Memo1.Lines.Append(RESTResponse1.Headers.Strings[I]); Memo1.Lines.Append(''); Memo1.Lines.Append('Body:'); tJson := TJSONObject.ParseJSONValue(RESTResponse1.Content); try memo1.Lines.Append(REST.Json.TJson.Format(tJson)); finally FreeAndNil(tJson); end; HideLoadingIndicator(Self); end; MyErrorCompletionHandler := procedure(AObject: TObject) begin Label1.Text := 'Error!'; HideLoadingIndicator(Self); end; RESTRequest1.ExecuteAsync(MyCompletionHandler, True, True, MyErrorCompletionHandler); end; result packet capture using app and this simple apps made with firemonkey: Simple Apps
Read More

Restrict user input to digits only with InputQuery

I've followed the Embarcadero documentation to provide an input dialog to let user give keyboard input (I followed the C++ example exactly). I know this is implemented with TEdit boxes internally, is it possible to restrict user input in the dialog to digits only (0-9)? I'm thinking something like we can do with regular TEdit boxes using the FilterChar property or somehow specify the KeyboardType property to NumberPad.
Read More

Android apps migration from Delphi 10.3.1 to 10.3.2

I have two problems after switching to 10.3.2 from 10.3.1 1) When I install the APK on the phone I get information "Google protect blocked APP.... " I have the same SDK version in 10.3.1 and 10.3.2. I get information only for APK under 10.3.2. What I should change ? 2) I can't run android projects created in 10.3.1 after compile in 10.3.2. I cleaned the library directory in my project. The application compiles, installs and then app stops on the default splash. UPDATE FOR POINT 2 - Problem solved
Read More

Inaccessible value from control on embedded child form (Delphi, Firemonkey)

I am new to Firemonkey (using RadStudio 10.3.2), and I am trying to update a listbox control on an embedded child form. However, when I try to access any of the properties of the listbox (ListBox1), they show up as "Inaccessible value." I'm pretty sure that I am missing something very simple. I appreciate any and all help! Thank you! I have made the following, simplified application, to illustrate my issue. Project1 Application Initialization: program Project1; uses System.StartUpCopy, FMX.Forms, Unit1 in 'Unit1.pas' {Form1}, Unit2 in 'Unit2.pas' {Form2}; {$R *.res} begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; end. Unit1.pas: unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Controls.Presentation, FMX.StdCtrls; type TForm1 = class(TForm) Panel1: TPanel; Button1: TButton; procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } procedure EmbedForm(AParent:TControl; AForm:TCustomForm); end; var Form1: TForm1; implementation {$R *.fmx} uses Unit2; procedure TForm1.FormCreate(Sender: TObject); begin // Embed Scenarios Form EmbedForm(Panel1, TForm2.Create(Self)); Panel1.Visible := true; end; procedure TForm1.Button1Click(Sender: TObject); var data_strings: array of string; begin // Assign strings SetLength(data_strings, 2); data_strings[0] := 'Hello'; data_strings[1] := 'World'; // Load strings Form2.ListBox1.Items.Add(data_strings[0]); Form2.ListBox1.Items.Add(data_strings[1]); end; procedure TForm1.EmbedForm(AParent: TControl; AForm: TCustomForm); begin while AForm.ChildrenCount>0 do AForm.Children[0].Parent:=AParent; end; end. Unit2.pas: unit Unit2; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Layouts, FMX.ListBox; type TForm2 = class(TForm) ListBox1: TListBox; private { Private declarations } public { Public declarations } end; var Form2: TForm2; implementation {$R *.fmx} end. The Form2.ListBox1 properties are inaccessable to the code on the main form--see the Button1Click event. I have the parent form (Unit1) using the child form (Unit2). I am at a loss as to why an enabled, visible component is inaccessible. My modal forms never had this issue, so I think it has to do with the embedded child form.
Read More

Open PDF file Delphi RIO

I would like to open a PDF that is allocated locally in my application (ANDROID only), but I am not getting it at all.

I already tried this link: Getting exception while opening PDF file for Android 26 using Firemonkey/Delphi but not work in Delphi RIO.

So I kept looking and got this code:

procedure TF_NovaART.PRO_MapeaClick(Sender: TObject);
var
  fName       : String;
  LIntent: JIntent;
  LAuthority: JString;
  LUri: Jnet_Uri;
begin
    fName := TPath.GetDocumentsPath + PathDelim + 'PRO_Topo.pdf';

    {$IFDEF ANDROID}
      LAuthority := StringToJString(JStringToString(TAndroidHelper.Context.getApplicationContext.getPackageName) + '.fileprovider');
      LUri := TJFileProvider.JavaClass.getUriForFile(TAndroidHelper.Context, LAuthority, TJFile.JavaClass.init(StringToJString(fName)));
      LIntent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_VIEW);
      LIntent.setDataAndType(LUri, StringToJString('application/pdf'));
      LIntent.setFlags(TJIntent.JavaClass.FLAG_GRANT_READ_URI_PERMISSION);
      TAndroidHelper.Activity.startActivity(LIntent);

    {$ENDIF}

end;

Which was found on this link: Getting exception while opening PDF file for Android 26 using Firemonkey/Delphi

I did exactly as it is written, but returns me the following error:

java;lang;NullPointerException: Attempt to invoke virtual method
‘android.content.res.XmlResourceParser android.content.pm.Package
ItemInfo.loadXmlMetaData(android.content.pm.PackageManager,
java.lang;String)’ on a null object reference

now it’s giving :

java.kabg.illegalArgumentExcpetion: Failed to find configurated root
that contains
/data/data/com.embarcadero.ART_Dinamica/files/PRO_Topo.pdf.

PS: I put my pdf (PRO_Topo.pdf) in the deployment and the remote patch is “.\assets\internal”

I think I need to put in the “AndroidManifest”, but I’ve already researched it and I’m not sure how to set it. (This bug has been stalking me for over a month. I skipped this part of the code to do other things, but again I’m unable to continue because of it)

The GIT link I got from the File Provider drive is this: https://github.com/DelphiWorlds/KastriFree/blob/master/API/DW.Androidapi.JNI.FileProvider.pas

If anyone can help me I will be sooo grateful.

Below I will leave my AndroidManifest.template.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="%package%"
        android:versionCode="%versionCode%"
        android:versionName="%versionName%"
        android:installLocation="%installLocation%">

    <uses-sdk android:minSdkVersion="%minSdkVersion%"        
    android:targetSdkVersion="%targetSdkVersion%" />
    <%uses-permission%>
    <uses-feature android:glEsVersion="0x00020000" android:required="True"/>
    <application android:persistent="%persistent%" 
        android:restoreAnyVersion="%restoreAnyVersion%" 
        android:label="%label%" 
        android:debuggable="%debuggable%" 
        android:largeHeap="%largeHeap%"
        android:icon="%icon%"
        android:theme="%theme%"
        android:hardwareAccelerated="%hardwareAccelerated%"
        android:resizeableActivity="false">

        <%provider%>
        <%application-meta-data%>
        <%services%>
        <!-- Our activity is a subclass of the built-in NativeActivity framework class.
             This will take care of integrating with our NDK code. -->
        <activity android:name="com.embarcadero.firemonkey.FMXNativeActivity"
                android:label="%activityLabel%"
                android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
                android:launchMode="singleTask">
            <!-- Tell NativeActivity the name of our .so -->
            <meta-data android:name="android.app.lib_name"
                android:value="%libNameValue%" />
            <intent-filter>  
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter> 
        </activity>
        <%activity%>
        <%receivers%>
    </application>
</manifest>
<!-- END_INCLUDE(manifest) -->

Now my AndroidManifest is:

<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="26" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<uses-feature android:glEsVersion="0x00020000" android:required="True"/>
<application android:persistent="False" 
    android:restoreAnyVersion="False" 
    android:label="ART_Dinamica" 
    android:debuggable="True" 
    android:largeHeap="False"
    android:icon="@drawable/ic_launcher"
    android:theme="@style/AppTheme"
    android:hardwareAccelerated="true"
    android:resizeableActivity="false">

    <provider
        android:name="android.support.v4.content.FileProvider"
        android:authorities="com.embarcadero.ART_Dinamica.fileprovider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data android:name="android.support.FILE_PROVIDER_PATHS"

android:resource=”@xml/provider_paths”/>

    <!-- Our activity is a subclass of the built-in NativeActivity framework class.
         This will take care of integrating with our NDK code. -->
    <activity android:name="com.embarcadero.firemonkey.FMXNativeActivity"
            android:label="ART_Dinamica"
            android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
            android:launchMode="singleTask">
        <!-- Tell NativeActivity the name of our .so -->
        <meta-data android:name="android.app.lib_name"
            android:value="ART_Dinamica" />
        <intent-filter>  
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter> 
    </activity>

    <receiver android:name="com.embarcadero.rtl.notifications.NotificationAlarm" />

</application> </manifest> <!-- END_INCLUDE(manifest) -->

My provider_paths.xml:

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
  <external-path name="external_files" path="."/>
</paths>

Deployment image

Read More

Read More

Implementing IInterface works in VCL but not in FMX

I have this interface called "IViewFrame" its implementation is like this: __interface INTERFACE_UUID("{D307ACE9-FE13-4F11-BEEB-A15C908579BC}") IViewFrame : public System::IInterface { //--------------------------------------------------------------------------- protected: //Setters/Getters virtual void __fastcall SetView(TView *Value) = 0; virtual TView* __fastcall GetView() = 0; //--------------------------------------------------------------------------- public: //Fields/Properties __property TView *View = {read = GetView, write = SetView}; //--------------------------------------------------------------------------- }; //--------------------------------------------------------------------------- typedef System::DelphiInterface<IViewFrame> _di_IViewFrame; Now on VCL this interface is working fine here is the code: class TVCLFrame : public TFrame, IViewFrame { __published: // IDE-managed Components private: //Fields TView *FView; //--------------------------------------------------------------------------- protected: //Setters/Getters virtual void __fastcall SetView(TView *Value); virtual TView* __fastcall GetView(); public: // User declarations __fastcall TVCLFrame(TComponent* Owner); INTFOBJECT_IMPL_IUNKNOWN(TFrame); }; //--------------------------------------------------------------------------- But when I do the same thing in an FMX Frame, I get a conflict error in INTFOBJECT_IMPL_IUNKNOWN: class TFmxFrame : public TFrame, IViewFrame { __published: // IDE-managed Components TBindingsList *BindingsList; TBindSourceDB *BindSourceDB; TBindNavigator *BindNavigator1; private: // User declarations TView *FView; protected: //Setters/Getters virtual void __fastcall SetView(TView *Value); virtual TView* __fastcall GetView(); public: // User declarations __fastcall TFmxFrame(TComponent* Owner); INTFOBJECT_IMPL_IUNKNOWN(TFrame); // I get the error here }; //--------------------------------------------------------------------------- [bcc32 Error] FmxFrameU.h(50): E2113 Virtual function '__stdcall TFmxFrame::Release()' conflicts with base class 'TFmxObject' Now I looked into TfmxObjct code and found out that there is another method called Release() that conflicts with the one from the IUnknown Interface. How can I fix this issue? I want this interface to work for both VCL and FMX without any troubles.
Read More

what is wrong with this use of goto?

I'm using a goto statement to skip a piece of code (as per documentation), just for testing purposes while I debug a block of code. I'm getting an error 1526, "goto into protected scope". This is totally trivial I know, but I want to know what is wrong with how I'm using the goto code: #if defined(_PLAT_ANDROID) _di_JIntent MyIntent; MyIntent = TJIntent::JavaClass->init(TJIntent::JavaClass->ACTION_VIEW, TJnet_Uri::JavaClass->parse(StringToJString("http://relayman.org/papers/2009_FDA_paper.pdf"))); TAndroidHelper::Activity->startActivity(MyIntent); goto Skipit; Androidapi::Jni::Graphicscontentviewtext::_di_JIntent intent = TJIntent::Create(); intent->setDataAndType(StringToJString("file://" + System::Ioutils::TPath::Combine(System::Ioutils::TPath::GetSharedDownloadsPath(), "sample.pdf")), StringToJString(L"application/pdf")); intent->setAction(TJIntent::JavaClass->ACTION_VIEW); intent->setFlags(TJIntent::JavaClass->FLAG_GRANT_READ_URI_PERMISSION); if (SharedActivity()->getPackageManager()->queryIntentActivities(intent, TJPackageManager::JavaClass->MATCH_DEFAULT_ONLY)->size() > 0) { SharedActivity()->startActivity(intent); } else { ShowMessage("PDF viewer not found"); } Skipit: #endif I'm working in 10.3.2 and building toward Android target.
Read More