-
Content Count
1560 -
Joined
-
Last visited
-
Days Won
36
Everything posted by Dave Nottage
-
Mine doesn't crash, however I find that sometimes it will not go to the declaration, despite the fact that the application compiles OK. Still trying to work out the source of the problem...
-
Renaming the app has the same effect. Certainly saves on having to restart the device 🙂
-
PowerManager (imported as JPowerManager) is in Androidapi.JNI.Os
-
It's because the tools are not as accurate as they could be, and the resulting source files often require adjustment. For iOS/macOS, at least some knowledge of translating Objective-C to Delphi is essential.
-
VKAutoShowMode variable. Set it to TVKAutoShowMode.Never when you don't want it to show. Change it back to TVKAutoShowMode.DefinedBySystem when you do.
-
Delphi 10.3 and supported version of Android
Dave Nottage replied to Yaron's topic in Delphi IDE and APIs
For what it's worth, I am involved in projects where we're supporting Android 4.4.4 on relatively "ancient" devices. I've been given permission to talk about the 10.4 beta (Disclaimer: As always, things may or may not change), so I can tell you that so far everything works on those devices using 10.4. The changes we needed to make were the minSdkVersion (set to 19) and NDK (note: not SDK) settings to target Android-21 (for version 5, but seems to work for 4.4.4). -
Delphi 10.3 and supported version of Android
Dave Nottage replied to Yaron's topic in Delphi IDE and APIs
You're welcome! I'm pretty sure that means that there's an existing app on the device where the certificate does not match the one of the app replacing it. This can be caused by using a new version of Delphi (or one from a different machine) to deploy the app, because the debug.keystore file in the %APPDATA%\Embarcadero\BDS\xx.x folder (where xx.x is 20.0, for Delphi 10.3) is different. One trick to fixing this is to use the debug.keystore file from the previous version, or just delete the app from the device before redeploying. Are you referring to the minSdkVersion issue? It'll happen whenever they decide to change the minimum supported version. The Android OS does not help in this regard when the device spits out a cryptic error message instead of saying "the minSdkVersion value is too high for this device" Google themselves already encourage people to upgrade their devices, because supporting a growing number of older versions is time consuming and costly. -
[Android][CameraComponent] How do I get a sharp image with Autofocus or other?
Dave Nottage replied to Fabian1648's topic in FMX
One way would be to use something other than the camera component in Delphi. Although it may need some work, you could try my camera project: https://github.com/DelphiWorlds/Camera I am reviving the project, however that may be some time away, so you might want to consider something else, like WinSoft's: https://www.winsoft.sk/acamera.htm -
[dccosx64 Error] E2597 ld: file not found: librtlhelper.a
Dave Nottage replied to erva's topic in FMX
Seems like your paths may have been messed up. In Tools|Options > Language > Delphi > Library for macOS 64-bit, it should look like this (not necessarily including the last 2): -
Using iOS LocalNotification with EKAlarm, EKEvent, EKEventStore as "short time, timer alarm"
Dave Nottage replied to Rollo62's topic in Cross-platform
Oddly enough, I started looking at that recently, to include images in push notifications (which is way easier on Android). Unfortunately, it requires an iOS app extension which you have to create with Xcode (not real hard to do, mind you). I have shelved it for the time being because I have not been able to make it work as yet. I hope to come back to it in the next few days.- 4 replies
-
- ios
- notification
-
(and 1 more)
Tagged with:
-
FCM App Server is returning with a "401: INVALID_KEY" Response
Dave Nottage replied to MikeMon's topic in Cross-platform
Does it need to be a "server"? I have this desktop app: https://github.com/DelphiWorlds/PushIt -
Using iOS LocalNotification with EKAlarm, EKEvent, EKEventStore as "short time, timer alarm"
Dave Nottage replied to Rollo62's topic in Cross-platform
What are the actual requirements for the short-time timer? Is it to display a notification? How short is the "short-time"? Any other requirements?- 4 replies
-
- ios
- notification
-
(and 1 more)
Tagged with:
-
[Android] Retrieving photos from the camera roll that have been taken in a Delphi app
Dave Nottage posted a topic in Cross-platform
I'm having an issue with being able to retrieve photos from the camera roll when using TTakePhotoFromCameraAction. It's probably not a bug; it's more likely a case of "yet to be implemented" 🙂 I've attached a project that demonstrates the issue. On startup the test app requests permission to read external storage, then if granted proceeds to retrieve the photos from the camera roll. This works fine. When the TakePhoto button is clicked, the app requests permissions for the camera and to write to external storage, then proceeds to execute the action. When the user has finished taking the photo, the TakePhotoFromCameraActionDidFinishTaking event fires, and the app reloads the photos from the camera roll. One would expect the newly taken photo to be in the roll, however it is not. Restarting the app still does not show the new photo. Running the Photos app on the device shows the new photo, however with a slight delay before it actually appears - I'm not sure if this is a clue. Restart the test app again, et voila! The new photo is there. The question is: why does the photo not appear when restarting the app (not that I'd expect anyone to do this), and not until the Photos app has been run? AndroidGetPhoto.zip -
[Android] Retrieving photos from the camera roll that have been taken in a Delphi app
Dave Nottage replied to Dave Nottage's topic in Cross-platform
After a lot of Googling and experimenting, I managed to solve this myself. From what I could gather, and this may apply only to later versions of Android (I have Android 10 on my Pixel 3a), the method that FMX uses to "scan" the image file into the gallery, which is via an intent (source\rtl\androiddex\java\fmx\src\com\embarcadero\firemonkey\medialibrary\MediaImage.java): /** * Adds photo to Gallery application. */ public void addPhotoToGallery() { Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); intent.setData(getFileUri()); activity.sendBroadcast(intent); } Does not immediately update the media "database". I discovered that using the scanFile method of the MediaScannerConnection class: https://developer.android.com/reference/android/media/MediaScannerConnection Does cause an immediate update, so that requerying using ContentResolver now works. I used the code in this article: https://www.grokkingandroid.com/adding-files-to-androids-media-library-using-the-mediascanner/ To come up with the additional Delphi code required, which is in the attached test app. I've added some comments which should clarify the whys and hows. AndroidGetPhotoV2.zip -
iOSapi_AVFoundation AVAudioSession extension doesn't work
Dave Nottage replied to Rollo62's topic in Cross-platform
I should have realised from the beginning - it's a method resolution problem. The Objective-C method name is actually setCategory, not setCategoryWithOptionsError, so it needs a MethodName attribute. This executes without error for me: uses Macapi.ObjectiveC, Macapi.Helpers, iOSapi.Foundation, iOSapi.AVFoundation, iOSapi.CocoaTypes; const AVAudioSessionCategoryOptionNone = 0; AVAudioSessionCategoryOptionMixWithOthers = 1; AVAudioSessionCategoryOptionDuckOthers = 2; AVAudioSessionCategoryOptionAllowBluetooth = 4; AVAudioSessionCategoryOptionDefaultToSpeaker = 8; AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers = 17; AVAudioSessionCategoryOptionAllowBluetoothA2DP = 32; AVAudioSessionCategoryOptionAllowAirPlay = 64; type AVAudioSessionCategory = NSString; AVAudioSessionCategoryOptions = NSInteger; AVAudioSessionClass = interface(NSObjectClass) ['{F8B0F7A3-1805-4739-B827-3AE7FFCD20F0}'] {class} function sharedInstance: Pointer; cdecl; end; AVAudioSession = interface(NSObject) ['{C6EAD2A6-DE66-4A80-B019-8564FF6927AF}'] function category: NSString; cdecl; function currentHardwareInputNumberOfChannels: NSInteger; cdecl; function currentHardwareOutputNumberOfChannels: NSInteger; cdecl; function currentHardwareSampleRate: double; cdecl; function delegate: Pointer; cdecl; function inputIsAvailable: Boolean; cdecl; function mode: NSString; cdecl; function preferredHardwareSampleRate: double; cdecl; function preferredIOBufferDuration: NSTimeInterval; cdecl; function setActive(beActive: Boolean; error: PPointer): Boolean; cdecl; overload; function setActive(beActive: Boolean; withFlags: NSInteger; error: PPointer): Boolean; cdecl; overload; function setCategory(theCategory: NSString; error: PPointer): Boolean; cdecl; [MethodName('setCategory:withOptions:error:')] function setCategoryWithOptionsError(category: AVAudioSessionCategory; withOptions: AVAudioSessionCategoryOptions; error: PPointer): Boolean; cdecl; procedure setDelegate(delegate: Pointer); cdecl; function setMode(theMode: NSString; error: PPointer): Boolean; cdecl; function setPreferredHardwareSampleRate(sampleRate: double; error: PPointer): Boolean; cdecl; function setPreferredIOBufferDuration(duration: NSTimeInterval; error: PPointer): Boolean; cdecl; end; TAVAudioSession = class(TOCGenericImport<AVAudioSessionClass, AVAudioSession>) end; procedure TForm1.Button1Click(Sender: TObject); var LSession: AVAudioSession; LErrorPtr: Pointer; begin LErrorPtr := nil; LSession := TAVAudioSession.Wrap(TAVAudioSession.OCClass.sharedInstance); if LSession.setCategoryWithOptionsError(AVAudioSessionCategoryPlayback, AVAudioSessionCategoryOptionNone, @LErrorPtr) then Label1.Text := 'Set category OK' else if LErrorPtr <> nil then Label1.Text := NSStrToStr(TNSError.Wrap(LErrorPtr).localizedDescription); end; -
As Bill said, it's a "we've been given permission" thing. This is not new, however - I think it has been a "thing" for at least a couple of major releases now. Also, you missed my post: https://www.delphiworlds.com/2020/05/its-time-to-get-excited/ 🙂
-
iOSapi_AVFoundation AVAudioSession extension doesn't work
Dave Nottage replied to Rollo62's topic in Cross-platform
Every time you see a NSError** you'll need to replace it with PPointer. Also, if you see: (NSError * _Nullable * _Nullable) (Which amounts to the same thing) I was just pointing out the incorrect declaration; I have not looked at any other aspect as yet. I'll take a look at your example today and see what the problem might be. -
iOSapi_AVFoundation AVAudioSession extension doesn't work
Dave Nottage replied to Rollo62's topic in Cross-platform
I think you mean in iOSapi.AVFoundation.pas. You're working under the assumption that the declaration is correct - it is not. Because the corresponding declaration in Objective-C is: - (BOOL)setCategory:(AVAudioSessionCategory)category error:(NSError **)outError Note the double asterisk. Because the Objective-C bridge is presently unable to handle wrapping this, a PPointer can be used in the way I described in my reply. As an example, see the code for the DownloadableContentPath method in FMX.InAppPurchase.iOS, which uses the setResourceValue method of NSURL, which is declared correctly. It's a QP report either way, however I'm referring to the missing declaration for the setCategoryWithOptionsError method of AVAudioSession (and any others methods that might be needed) in iOSapi.AVFoundation. No, that's not automatic. It would be nice if it were, however translating SDK framework headers is not trivial, and as you've observed declaration errors can happen, and/or the Objective-C bridge needs to be modified to handle situations where needed. Up until 10.3.2 (or somewhere close to that), the bridge could not even handle Objective-C blocks on macOS (it could on iOS). -
On iOS, you cannot do it programmatically without user interaction; namely: if you post a local notification and the user taps the notification.
- 11 replies
-
- ios
- background
-
(and 1 more)
Tagged with:
-
iOSapi_AVFoundation AVAudioSession extension doesn't work
Dave Nottage replied to Rollo62's topic in Cross-platform
It should be: function setCategoryWithOptionsError(category: NSString; withOptions: AVAudioSessionCategoryOptions; error: PPointer): Boolean; cdecl; But you don't show how you're calling it, either. A possible example: var LErrorPtr: Pointer; LError: NSError; ... setCategoryWithOptionsError(CocoaNSStringConst(libAVFoundation, 'AVAudioSessionCategoryPlayAndRecord'), 0, @LErrorPtr); if LErrorPtr <> nil then begin LError := TNSError.Wrap(LErrorPtr); // Deal with LError here end; You should. No. I suggest filing a QP report. -
iOS Bluetooth LE with background-central stops after 1-10 minute
Dave Nottage replied to Rollo62's topic in Cross-platform
My first guess would be that the data rate is too fast for too long, and iOS kills your app. Before I dive headlong into a deeper look, you might want to read this: https://stackoverflow.com/a/34122794/3164070 ..which links to: https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html- 6 replies
-
- ios
- bluetooth le
-
(and 3 more)
Tagged with:
-
Moving on from my prior question, I have posted this on SO, however I've started a new thread here in case someone that can help might otherwise miss it 🙂 My prior question here: Post on SO for the current problem: https://stackoverflow.com/questions/61514990/setting-an-enum-property-on-a-net-object
-
Thread programming without sleep or WaitFor events
Dave Nottage replied to turkverisoft's topic in Delphi IDE and APIs
Then you should not be using UDP, since order of packets is not guaranteed. With UDP, every packet should be considered data independent of all others. -
WebBroker option not visible in File > New > Other >Delphi projects after installing Delphi 10.3.3
Dave Nottage replied to Ramu's topic in Delphi IDE and APIs
It's not entirely obvious from File|New|Other|Delphi. From there, select the Web folder, and Web Server Application. They're all WebBroker solutions, but that's also not obvious until the second page. -
I have some .NET interop code where I've managed to load objects and read properties, however I am having trouble with setting a property on an object. Here's the relevant parts of the Delphi code: uses mscorlib_TLB, Winapi.ActiveX; type // Irrelevant parts of the code omitted TDotNetObject = class(TObject) private FTarget: OleVariant; FType: _Type; public procedure SetProperty(const APropertyName: string; const AValue: OleVariant; const AIndex: Integer = -1); end; function VariantToPSafeArray(const AValue: Variant): PSafeArray; begin Result := PSafeArray(VarArrayAsPSafeArray(AValue)); end; procedure TDotNetObject.SetProperty(const APropertyName: string; const AValue: OleVariant; const AIndex: Integer = -1); var LPropertyInfo: _PropertyInfo; LIndex: PSafeArray; begin if AIndex >= 0 then LIndex := VariantToPSafeArray(VarArrayOf([AIndex])) else LIndex := nil; LPropertyInfo := FType.GetProperty(APropertyName, BindingFlags_Instance or BindingFlags_Public or BindingFlags_NonPublic); if LPropertyInfo <> nil then LPropertyInfo.SetValue(FTarget, AValue, LIndex); end; procedure UpdateDefectStatus(const ADefectID, AStatus: Integer); var LObject: TDotNetObject; begin // ** Code to obtain the object omitted *** LObject.SetProperty('Status', AStatus); end; An error is thrown when LPropertyInfo.SetValue is called in TDotNetObject.SetProperty: The Status property type in C# is declared: public enum DefectStatus { /// <summary> /// Defect Reported. /// </summary> Reported, /// <summary> /// Defect assessed. /// </summary> Assessed, /// <summary> /// Defect on work order. /// </summary> OnWorkOrder, /// <summary> /// Defect closed. /// </summary> Closed } I found a solution for how to handle this situation using C# here: https://stackoverflow.com/a/13270302/3164070 However I'm a bit lost as to how to do the same in Delphi. Any ideas?