-
Content Count
1490 -
Joined
-
Last visited
-
Days Won
36
Everything posted by Dave Nottage
-
Android 13 ask permission for push notification
Dave Nottage replied to John van de Waeter's topic in Cross-platform
Yes, you will need to manually add the permission to the manifest - one way is to modify AndroidManifest.template.xml to add: <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/> A suitable location would be just below <%uses-permission%> You will also need to request the permission in your code, e.g: PermissionsService.RequestPermissions(['android.permission.POST_NOTIFICATIONS'], procedure(const APermissions: TClassicStringDynArray; const AGrantResults: TClassicPermissionStatusDynArray) begin if AGrantResults[0] = TPermissionStatus.Granted then // Permission was granted end ); -
android how can i handle the javascript result?
Dave Nottage replied to sail2000's topic in Cross-platform
This could be one way: 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.WebBrowser, FMX.Controls.Presentation, FMX.StdCtrls, FMX.Edit, Androidapi.JNIBridge, Androidapi.JNI.WebKit, Androidapi.JNI.JavaTypes; type TJavaScriptResultEvent = procedure(Sender: TObject; const JavaScriptResult: string) of object; TJavaScriptValueCallback = class(TJavaLocal, JValueCallback) private FOnResult: TJavaScriptResultEvent; public { JValueCallback } procedure onReceiveValue(value: JObject); cdecl; public property OnResult: TJavaScriptResultEvent read FOnResult write FOnResult; end; TForm1 = class(TForm) WebBrowser: TWebBrowser; Button1: TButton; Edit1: TEdit; procedure Button1Click(Sender: TObject); private FJavaScriptValueCallback: TJavaScriptValueCallback; procedure NewDateResultHandler(Sender: TObject; const AJavaScriptResult: string); public constructor Create(AOwner: TComponent); override; destructor Destroy; override; end; var Form1: TForm1; implementation {$R *.fmx} uses Androidapi.Helpers; { TJavaScriptValueCallback } procedure TJavaScriptValueCallback.onReceiveValue(value: JObject); begin if Assigned(FOnResult) then FOnResult(Self, JStringToString(TJString.Wrap(value)).DeQuotedString('"')); end; { TForm1 } constructor TForm1.Create(AOwner: TComponent); begin inherited; FJavaScriptValueCallback := TJavaScriptValueCallback.Create; end; destructor TForm1.Destroy; begin FJavaScriptValueCallback.Free; inherited; end; procedure TForm1.NewDateResultHandler(Sender: TObject; const AJavaScriptResult: string); begin Edit1.Text := AJavaScriptResult; end; procedure TForm1.Button1Click(Sender: TObject); var LWebView: JWebView; begin if Supports(WebBrowser, JWebView, LWebView) then begin FJavaScriptValueCallback.OnResult := NewDateResultHandler; LWebView.evaluateJavascript(StringToJString('new Date()'), FJavaScriptValueCallback); end; end; end. -
Delphi FMX Android - blocking push notifications permissions
Dave Nottage replied to Piotr Daszewski's topic in General Help
Modified code from the DW.FCMManager unit from this demo: function IsPushEnabled(const AChannelId: string): Boolean; var LService: JObject; LNotificationManager: JNotificationManager; LChannels: JList; LChannel: JNotificationChannel; I: Integer; begin LService := TAndroidHelper.Context.getSystemService(TJContext.JavaClass.NOTIFICATION_SERVICE); LNotificationManager := TJNotificationManager.Wrap(TAndroidHelper.JObjectToID(LService)); Result := LNotificationManager.areNotificationsEnabled; if Result and (TJBuild_Version.JavaClass.SDK_INT >= 26) then begin LChannels := LNotificationManager.getNotificationChannels; for I := 0 to LChannels.size - 1 do begin LChannel := TJNotificationChannel.Wrap(LChannels.get(I)); if LChannel.getId.equals(StringToJString(AChannelId)) and (LChannel.getImportance = TJNotificationManager.JavaClass.IMPORTANCE_NONE) then begin Result := False; Break; end; end; end; end; -
Google Translate says it is: "You are the man!"... I'll take that, thanks! 🙂
-
Earlier, you said: If it does not run, the main form would not be displayed
-
Your intent-filter node is missing from the manifest. The activity node should look like this: <activity android:name="com.embarcadero.firemonkey.FMXNativeActivity" android:label="MixPDV" android:exported = "true" 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="MixPDV" /> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
-
Did you set the option to generate 32-bit and 64-bit binaries in the Project Options?
-
If the breakpoints are not disabled - ie like this: Then the code isn't being reached. Yet when you removed that part, the code in unit main executes? This is where a reproducible example would help.
-
There's a difference between a breakpoint being disabled (which is indicated visually), versus one where the debugger does not stop. The latter can happen because the code where you have the breakpoint is never reached and/or you have a unit with the same name, and you're looking at the wrong one. Something specific to the platform. Detailing what you have in your datamodule might help (eg. data components used, what type of connection e.g SQLite, etc)
-
So the problem is with the datamodule. Still? The screenshot you showed in an earlier message indicates they were not. Are you compiling for Debug?
-
It's not advisable to have conditionals in your .dpr because the IDE can be prone to mess it up. In this case, the conditional for the Android unit is pointless anyway, since nothing from it is being referenced in the .dpr. This would not be the cause of your issue, but it's still something to consider. As @programmerdelphi2k inferred, it may be being caused by something happening in untDataModule. You could use the debugger to see what is executed there when it is created. Has it ever run OK on iOS? Either way, you could remove parts of the application that were previously added, to help isolate what is causing the lockup.
-
You would have needed to have downloaded your developer profile, so I was assuming you knew how already.
-
You need to create an Application ID (on the Apple Developer site, this is Identifiers), In general, you won't need to select any entitlements unless you plan on having Push Notifications in your app, in which case select that entitlement from the list For Description, use a description about your application (e.g. just the name), and for Bundle ID, the convention is to use a domain you have, in reverse, then the name of the application. The Description and Bundle ID pictured are just examples. You will also need a Provisioning Profile (in Profiles) for App Store:
-
contacts sample application does not want to run on device
Dave Nottage replied to William23668's topic in FMX
This demo starts/works OK on my Pixel 6 Pro, which has Android 13. I'm using Delphi 11.2 with Patch 1 installed. https://github.com/Embarcadero/RADStudio11Demos/tree/main/Object Pascal/Multi-Device Samples/Device Sensors and Services/Address Book/Contacts -
contacts sample application does not want to run on device
Dave Nottage replied to William23668's topic in FMX
Which version of Delphi are you using? Which version of Android is on the device? Have you tried running the app via the debugger to check whether there's any errors? -
You execute them from the machine that is connected to the device. adb is in the platform-tools folder of the Android SDK
-
There's no instruction there to reinstall Delphi.
-
Please see: https://github.com/DelphiWorlds/HowTo/tree/main/Solutions/AndroidLibraries
-
Do you have a Provisioning Profile for App Store?
-
delphi 11 android app error "Application does not support this device"
Dave Nottage replied to KMarb's topic in FMX
See: -
I think you mean Provisioning Profile, but given your comment here, you have resolved that now?
-
Have you installed PAServer? Please refer to: https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Installing_the_Platform_Assistant_on_a_Mac ..and: https://docwiki.embarcadero.com/RADStudio/Alexandria/en/IOS_Mobile_Application_Development
-
One way would be to have a real device. What is the reason for wanting to test specifically on that? You should not need to.
-
Detect when/what makes a tcomponet descendent is made NIL?
Dave Nottage replied to alogrep's topic in VCL
You could at least post the code for whatever the method is that starts with "ProcessH", as per my earlier comment. You provided a screenshot and said that is where the problem occurs. -
Detect when/what makes a tcomponet descendent is made NIL?
Dave Nottage replied to alogrep's topic in VCL
Then the problem is not actually happening inside that procedure (though the root cause may be there). The problem is occurring in a method in the Http unit, in a class called TTCPHttpThrd in a method with a name starting with "ProcessH", but the rest of the callstack window is cut off in your screenshot