Jump to content

pcplayer99

Members
  • Content Count

    40
  • Joined

  • Last visited

Community Reputation

6 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. pcplayer99

    TThread issue

    T := TMyThread.Create(True); T.Start; equal: T := TMyThread.Create; After T := TMyThread.Create this thread run immediately. I write this: T := TMyThread.Create(True); T.Start; just want to place a break point here when thread was created and see what happend. And I have seen something: when there is a break point, and program stopped here, and then I press F8, and F8, it works fine. So I guess that maybe I can stop here for some while and I add a Sleep(500) here and it works fine.
  2. pcplayer99

    TThread issue

    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.StdCtrls, FMX.Controls.Presentation; type TForm1 = class(TForm) ToolBar1: TToolBar; Button1: TSpeedButton; procedure Button1Click(Sender: TObject); private { Private declarations } FNumb: Integer; public { Public declarations } end; TMyThread = class(TThread) private procedure aaaa; public procedure Execute; override; end; var Form1: TForm1; implementation {$R *.fmx} { TMyThread } procedure TMyThread.aaaa; begin Form1.Button1.Text := 'aaa' + Form1.FNumb.ToString; Form1.Updated; Inc(Form1.FNumb); end; procedure TMyThread.Execute; begin inherited; Self.Synchronize(aaaa); end; procedure TForm1.Button1Click(Sender: TObject); var T: TMyThread; begin T := TMyThread.Create(True); T.Start; end; end. Above code can run OK under Windows, but in Android, it can not run into TMyThread.Execute; if Add a Sleep(500) as code below, it can run OK in Android: procedure TForm1.Button1Click(Sender: TObject); var T: TMyThread; begin T := TMyThread.Create(True); Sleep(500); T.Start; end; So, I guess in Android, var T is a local variable and after exit Button1Click method, it was released by ARC. So I move var T: TMyThread declare to global variable at var Form1: TForm, and then delete Sleep(500) and then tested in Android, it works OK.
  3. PODBALMMSG2 = ^ODBALMMSG2; ODBALMMSG2 = packed record alm_no: LongInt; atype: SmallInt; axis: SmallInt; dummy: SmallInt; msg_len: SmallInt; alm_msg: array [0 .. 63] of AnsiChar; end; In Delphi,if you has code like this: procedure DoSometiing(xxxxx: xx); var MyR: ODBALMMSG2 begin ////do something... end; Here, you got a record MyR, its memory is prepared statically. It is a instance, you can use it directly. And the pointer of this instance is: @MyR. If you has code like this: procedure DoSometing(xxx: xxx); var MyR_P: PODBALMMSG2 begin /// Here, MyR_P is a pointer that type is PODBALMMSG2 but it is a pointer, you can just use a normal pointer type instead PODBALMMSG2. /// Here, MyR_P is just a variable, there is no instance, no memory that store data. If you want use it, you must allocate memory for it. And, you must free the memory when you want to give up it. MyR_P := GetMem(SizeOf(ODBALMMSG2)); try do something... finally FreeMem(MyR_P); end; /// or, you can use this function: New(MyR_P); try Do something.... finally Dispose(MyR_P); end; end;
  4. I remember Fmx TWebBrowser can be called javascript by delphi outside the TWebBrowser.
  5. pcplayer99

    TWebBrowser + dynamic JS question

    I did some research about this topic. It seems that we should use some "Headless Browser" with Python. But I try to use delphi. So, I have tested using outerHTML, innerHTML etc, and I have tested another way: Copy/Paste. And, I can got the HTML text but with some JS code or HTML tag. I can not get plain text that user can read at all.
  6. Just a test program, too simple: TForm1 = class(TForm) ToolBar1: TToolBar; SpeedButton1: TSpeedButton; MediaPlayer1: TMediaPlayer; MediaPlayerControl1: TMediaPlayerControl; Layout1: TLayout; ProgressBar1: TProgressBar; Timer1: TTimer; Layout2: TLayout; Label1: TLabel; procedure SpeedButton1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure FormShow(Sender: TObject); private { Private declarations } function GetMyFileName: string; procedure GetPermissions; public { Public declarations } end; There are some code copy from "RADStudio10.3Demos-master\Object Pascal\Mobile Snippets\VideoPlayback" : procedure TForm1.Timer1Timer(Sender: TObject); begin if ProgressBar1.Max <> MediaPlayer1.Duration then ProgressBar1.Max := MediaPlayer1.Duration; if ProgressBar1.Value <> MediaPlayer1.CurrentTime then ProgressBar1.Value := MediaPlayer1.CurrentTime; end; Compile IDE: Delphi 10.3.1 Community version. Test environment: A. Android 5.0; B. Android 9.0; Issues: 1. If there is no MediaPlayerControl1, under Android 5.0 it can play MP4 video file, can hear audio playing of this MP4 file, and ProgressBar1 working fine . But if there is a MediaPlayerControl1, after I call MediaPlayer1.Play, APP will raise a exception: Project testMediaPlayer.apk raised exception class EJNIException with message 'java.io.IOException: Prepare failed.: status=0x80000000'. 2. Under Android 9.0, it can play MP4 video, but ProgressBar1 can not work. Set up a break-point on "if ProgressBar1.Max <> MediaPlayer1.Duration then" every time the timer1 trigger, MediaPlayer1.Duration is -1.
  7. pcplayer99

    Android, how to call a TJIntent

    I update my code from uri := StrToJURI('file://' + AURI); to: LUri := TAndroidHelper.JFileToJURI(TJFile.JavaClass.init(StringToJString(AFileName))); and it works. Thanks Dave.
  8. Delphi 10.3.1 My steps: 1. BluetoothLE1.DiscoverDevices(3000); Can find device, trigger BluetoothLE1EndDiscoverDevices event. 2. FDevice.DiscoverServices; can get services. I can got a service by: AService := BluetoothLE1.GetService(FDevice, MyService_ID); 3. and then if I call: ACharacteristic := BluetoothLE1.GetCharacteristic(AService, My_Characteristic_ID); I got nil. ----------- at 3, this method will be ok: for I := 0 to AService.Characteristics.Count -1 do begin if Aservice.Characteristics.UUID = My_Characteristic_ID then begin ACharacteristic := Aservice.Characteristics; Break; end; end; After I do this for loop, ACharacteristic := BluetoothLE1.GetCharacteristic(AService, My_Characteristic_ID); will get the right thing. So, Is it a issue?
  9. pcplayer99

    Android, how to call a TJIntent

    Thank you Dave. I have tested, checked Secure File Sharing, and the exception is still raising.
  10. pcplayer99

    SOAP response cannot be read

    Maybe I know what issue it is. The reason is that server side use some .Net Object that Delphi can not handle. for a example: If I create SOAP server by Delphi, and I will create a client side by delphi, I can output TDataSetProvider from the server and my Delphi client can handle it but C# or Java can not. Here maybe your server write by C# and it useing some Object just by C# ?
  11. pcplayer99

    SOAP response cannot be read

    The exception is clear: SOAP classes must derive from TRemotable If you write SOAP code with using DELPHI, you must know, in SOAP interface methods, if the data type is a object, it must derive from TRemotable. If it is a TComponent, it can not using in SOAP method. Here I mean is that you design a SOAP server. If there is a running SOAP server, you can using "Component/import WSDL" menu in Delphi IDE menu, and Delphi will create some SOAP client code for you.
  12. pcplayer99

    Android, how to call a TJIntent

    On Android 6, I can play MP4 by call TJIntent: uri := StrToJURI('file://' + AURI); Intent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_VIEW); intent.setDataAndType(uri, StringToJstring('video/mp4')); TAndroidHelper.Activity.startActivity(Intent); On Android 9, there is a exception: raised exception class EJNIException with message 'android.os.FileUriExposedException: file:///storage/emulated/0/Download/VIDOES/4114049.mp4 exposed beyond app through Intent.getData() I have googled on Internet, it must use file provider. There is a demo code in: https://community.idera.com/developer-tools/platforms/f/android-platform/68376/my-apps-autoupdate-not-working-rio-10-3-1-tokyo-10-2-3-working and in this link: https://www.delphiworlds.com/2018/06/targeting-android-8-and-higher-continued/ it is said that we need add some provider code into AndroidManifest.template. So, I write code like this: AJavaFile := TJFile.JavaClass.init(StringToJstring( AURI)); uri := TAndroidHelper.JFileToJURI(AJavaFile); and update AndroidManifest.template file add some code in it: <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%> <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.embarcadero.firemonkey.fileprovider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths"/> </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> another XML file is provider_paths.xml, like this: <?xml version="1.0" encoding="utf-8"?> <paths xmlns:android="http://schemas.android.com/apk/res/android"> <external-path name="external_files" path="."/> </paths> but when call "uri := TAndroidHelper.JFileToJURI(AJavaFile); " there is a exception: raised exception class EJNIException with message 'java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference'. So, is there a demo that how to call a TJIntent on Android 7 or higher version?
  13. pcplayer99

    Android 8.0 Permissions errors using Delphi Rio 10.3

    I did a test, when the system dialog box show, I select "No", then AOnDisplayRationale show my dialog box.
  14. pcplayer99

    Android 8.0 Permissions errors using Delphi Rio 10.3

    Maybe this issue in my Android phone, is that the phone system show a policy dialogbox and I have selected OK, so it is the reason the AOnDisplayRationale can not call.
×