Jump to content

pcplayer99

Members
  • Content Count

    36
  • Joined

  • Last visited

Community Reputation

5 Neutral

Recent Profile Visitors

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

  1. 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.
  2. 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.
  3. 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.
  4. 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?
  5. pcplayer99

    Android, how to call a TJIntent

    Thank you Dave. I have tested, checked Secure File Sharing, and the exception is still raising.
  6. 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# ?
  7. 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.
  8. 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?
  9. 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.
  10. 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.
  11. pcplayer99

    Android 8.0 Permissions errors using Delphi Rio 10.3

    I run test app on Android 9, under debug mode, step by step, press F7 when it stoped on this: PermissionsService.RequestPermissions([FLocationPermission], RequestPermissionsResult, DisplayRationale); But it can not go into the implementation code, it go into some ASM code in function _InstClear(var Dest: TObject): Pointer; in system unit. In the same condition, if I press Ctr + Left click RequestPermissions, it go into: procedure TPermissionsService.RequestPermissions(const APermissions: TArray<string>; const AOnRequestPermissionsResult: TRequestPermissionsResultEvent; AOnDisplayRationale: TDisplayRationaleEvent); So, check this procedure in System.Permissions, there is no code to call AOnDisplayRationale.
  12. pcplayer99

    Android 8.0 Permissions errors using Delphi Rio 10.3

    On my Android Phone, Android version is 9. I tested BLEScanner demo, the method "TForm6.DisplayRationale" never be called when I call "PermissionsService.RequestPermissions([FLocationPermission], RequestPermissionsResult, DisplayRationale);"
  13. pcplayer99

    Android 8.0 Permissions errors using Delphi Rio 10.3

    There is a demo named BLEScanner with Delphi. In this demo, you can find some code about permission: procedure TForm6.btnStartScanClick(Sender: TObject); begin PermissionsService.RequestPermissions([FLocationPermission], RequestPermissionsResult, DisplayRationale); end; procedure TForm6.DisplayRationale(Sender: TObject; const APermissions: TArray<string>; const APostRationaleProc: TProc); begin TDialogService.ShowMessage('We need to be given permission to discover BLE devices', procedure(const AResult: TModalResult) begin APostRationaleProc; end) end; procedure TForm6.RequestPermissionsResult(Sender: TObject; const APermissions: TArray<string>; const AGrantResults: TArray<TPermissionStatus>); begin // 1 permissions involved: ACCESS_COARSE_LOCATION if (Length(AGrantResults) = 1) and (AGrantResults[0] = TPermissionStatus.Granted) then StartBLEDiscovery else TDialogService.ShowMessage('Cannot start BLE scan as the permission has not been granted'); end; But because the bug, DisplayRationale never be called.
  14. pcplayer99

    Android 8.0 Permissions errors using Delphi Rio 10.3

    In Delphi rio 10.3 Comunity edition, permission framework is in System.Permissions.pas. But, there are some bugs ? There are two method that we can request permission to call it. But the parameter "AOnDisplayRationale" has never be used by these two methods. procedure TPermissionsService.RequestPermissions(const APermissions: TArray<string>; const AOnRequestPermissionsResult: TRequestPermissionsResultEvent; AOnDisplayRationale: TDisplayRationaleEvent); var GrantResults: TArray<TPermissionStatus>; I: Integer; begin SetLength(GrantResults, Length(APermissions)); for I := Low(GrantResults) to High(GrantResults) do GrantResults[I] := TPermissionStatus.Granted; AOnRequestPermissionsResult(Self, APermissions, GrantResults) end; procedure TPermissionsService.RequestPermissions(const APermissions: TArray<string>; const AOnRequestPermissionsResult: TRequestPermissionsResultProc; AOnDisplayRationale: TDisplayRationaleProc); var GrantResults: TArray<TPermissionStatus>; I: Integer; begin SetLength(GrantResults, Length(APermissions)); for I := Low(GrantResults) to High(GrantResults) do GrantResults[I] := TPermissionStatus.Granted; AOnRequestPermissionsResult(APermissions, GrantResults) end;
×