Jump to content

Dave Nottage

Members
  • Content Count

    1489
  • Joined

  • Last visited

  • Days Won

    36

Everything posted by Dave Nottage

  1. Dave Nottage

    Your RAD Studio 10.4 Sydney issues

    For what it is worth: I understand your pain (having had similar issues in the past), and hope that it will be resolved soon
  2. Dave Nottage

    Your RAD Studio 10.4 Sydney issues

    Same here, however... ..this may be the case for you, however it is extremely usable for me. Making generalisations like this may discourage others from using it where it may well be quite usable for them.
  3. Dave Nottage

    How check VPN Active on Android?

    That code just checks if the network being examined has VPN capability, not if it is actually available, nor if it is connected. Note that a device can have an active VPN connection as well as other active connections. For guidance, you may wish to look at the Java examples here: https://www.codota.com/code/java/methods/android.net.NetworkCapabilities/hasTransport and here: https://www.codota.com/code/java/methods/android.net.NetworkCapabilities/hasTransport (specifically example 19)
  4. Dave Nottage

    ZXing Delphi for 10.4

    They should not be providing entire source files. If they are, they're very likely violating copyright. I'm working on one, which is a total revamp of this project: https://github.com/DelphiWorlds/Camera. If you're interested, please join my Slack team, here: https://slack.delphiworlds.com, and go to the #kastri channel.
  5. Dave Nottage

    Your RAD Studio 10.4 Sydney issues

    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...
  6. Dave Nottage

    StoryBoard launch screen - Delphi 10.4

    Renaming the app has the same effect. Certainly saves on having to restart the device 🙂
  7. Dave Nottage

    Android.JNI.PowerManager not found

    PowerManager (imported as JPowerManager) is in Androidapi.JNI.Os
  8. Dave Nottage

    Record and process audio

    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.
  9. Dave Nottage

    Manual handling of virtual keyboard

    VKAutoShowMode variable. Set it to TVKAutoShowMode.Never when you don't want it to show. Change it back to TVKAutoShowMode.DefinedBySystem when you do.
  10. Dave Nottage

    Delphi 10.3 and supported version of Android

    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).
  11. Dave Nottage

    Delphi 10.3 and supported version of Android

    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.
  12. 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
  13. Dave Nottage

    [dccosx64 Error] E2597 ld: file not found: librtlhelper.a

    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):
  14. 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.
  15. Does it need to be a "server"? I have this desktop app: https://github.com/DelphiWorlds/PushIt
  16. 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?
  17. 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
  18. 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
  19. 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;
  20. Dave Nottage

    Rx10.4 new feature blogs

    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/ 🙂
  21. 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.
  22. 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).
  23. Dave Nottage

    Return background to foreground

    On iOS, you cannot do it programmatically without user interaction; namely: if you post a local notification and the user taps the notification.
  24. 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.
  25. 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
×