Jump to content

Dave Nottage

Members
  • Content Count

    1560
  • Joined

  • Last visited

  • Days Won

    36

Everything posted by Dave Nottage

  1. Dave Nottage

    Squint and read: CreateFormFromStings

    ..or very few using that method, or very few that are vocal about the misspelling 😉
  2. Dave Nottage

    Squint and read: CreateFormFromStings

    It was introduced in 10.3 You're right that it's not a good look. If it were me, I'd change it and take the small amount of pain (if any) from developers, who would probably understand anyway
  3. It has always needed location permissions, they just don't need to have been requested at runtime prior to Android 6.
  4. Dave Nottage

    Call from sim 2

    Actually putExtra takes a number of different types, including JParcelable. I've modified the Telecom import unit: https://github.com/DelphiWorlds/KastriFree/blob/master/API/DW.Androidapi.JNI.Telecom.pas So if you update that, it should now accept LAccountHandle
  5. Dave Nottage

    Call from sim 2

    That part should be more like this: LAccounts := TJTelecomManager.Wrap(TAndroidHelper.JObjectToID(LService)).getCallCapablePhoneAccounts; if LAccounts <> nil then begin for I := 0 to 1 do begin if LAccounts.size > I then begin LPhoneAccountHandle := TJPhoneAccountHandle.Wrap(TAndroidHelper.JObjectToID(LAccounts.get(I))); Intent.putExtra(StringToJString('android.telecom.extra.PHONE_ACCOUNT_HANDLE'), LPhoneAccountHandle); end; end; end;
  6. Happens to me, too. It seems to key on "error:" (i.e. with a colon) because this produces the same result: @echo There was not one error: everything is OK
  7. Dave Nottage

    Call from sim 2

    I've created a more compatible (with the other Delphi units) import for the Telecom classes, here: https://github.com/DelphiWorlds/KastriFree/blob/master/API/DW.Androidapi.JNI.Telecom.pas Which should at least make it a bit easier
  8. Dave Nottage

    Call from sim 2

    This is one way: if TOSVersion.Check(21) then begin // Do the TELECOM_SERVICE stuff end; TELECOM_SERVICE was introduced in API level 21. Another way is: if TJBuild_VERSION.JavaClass.SDK_INT >= 21 then begin // Do the TELECOM_SERVICE stuff end;
  9. Unless someone has done it already, I expect you're going to need to spend a fair amount of time on it. This is a starting point for the leaderboard/game saving parts: https://developers.google.com/games/services/android/leaderboards It would be a case of: Reading the documentation, and working out which parts you want to implement Working out which packages the relevant classes are in Doing imports of those classes into Delphi code Working out whether there are any classes you need to create descendants for, and writing the appropriate Java and associated Delphi code for them Implementing the various parts in Delphi Alternatively, you could implement a large portion of it in Java, create a .jar that Delphi would use and import the relevant parts into Delphi code. I note that it requires Google Sign-in, so for that part you might want to take a look at this: https://github.com/grijjy/DelphiGoogleSignIn Which is related to Firebase, however the Google Sign-In parts would be relevant.
  10. Dave Nottage

    Call from sim 2

    There's an import for TelecomManager, here: https://github.com/FMXExpress/android-object-pascal-wrapper/blob/master/android-28/android.telecom.TelecomManager.pas Be aware that Java2Pas (which was used for the import) sometimes puts instance methods where the class methods are, so they should be removed from there in the import. getCallCapablePhoneAccounts is an instance method that returns a JList, containing instances of JPhoneAccountHandle, so one way to access them is to do this: var LService: JObject; LAccounts: JList; LPhoneAccountHandle: JPhoneAccountHandle; I: Integer; begin Result := False; LService := TAndroidHelper.Context.getSystemService(TJContext.JavaClass.TELECOM_SERVICE); LAccounts := TJTelecomManager.Wrap(TAndroidHelper.JObjectToID(LService)).getCallCapablePhoneAccounts; for I := 0 to LAccounts.size - 1 do begin LPhoneAccountHandle := TJPhoneAccountHandle.Wrap(TAndroidHelper.JObjectToID(LAccounts.get(I))); // Do whatever with the LPhoneAccountHandle here end; end; An import for PhoneAccountHandle is here: https://github.com/FMXExpress/android-object-pascal-wrapper/blob/master/android-28/android.telecom.PhoneAccountHandle.pas Note that getCallCapablePhoneAccounts was introduced in API level 23.
  11. I was originally using some Indy code, however I figured I strip back the code to the absolute basics in order to try and find out what is going wrong. This is the result: uses Posix.SysSocket, Posix.NetinetIn, Posix.ArpaInet; const // IPv6 address of en0 on my Mac cIPv6 = 'fe80::ca9:418d:c487:cba'; cPort = 9099; procedure TForm1.Button1Click(Sender: TObject); var LHandle, LOption, LError: Integer; LSockAddrIPv6: sockaddr_in6; LNetAddrIPv6: in6_addr; LMarshaller: TMarshaller; LMsg: string; begin LHandle := socket(AF_INET6, SOCK_DGRAM, 0); if LHandle > 0 then begin LOption := 1; if setsockopt(LHandle, SOL_SOCKET, SO_REUSEADDR, LOption, SizeOf(LOption)) = 0 then begin if inet_pton(AF_INET6, LMarshaller.AsAnsi(cIPv6).ToPointer, @LNetAddrIPv6) = 1 then begin FillChar(LSockAddrIPv6, SizeOf(LSockAddrIPv6), 0); LSockAddrIPv6.sin6_len := SizeOf(LSockAddrIPv6); LSockAddrIPv6.sin6_family := AF_INET6; LSockAddrIPv6.sin6_addr := LNetAddrIPv6; LSockAddrIPv6.sin6_port := htons(cPort); if bind(LHandle, PSockAddr(@LSockAddrIPv6)^, SizeOf(LSockAddrIPv6)) = -1 then begin LError := GetLastError; ShowMessage(SysErrorMessage(LError)); end; end; end; end; end; The bind fails, however I'm yet to be able to ascertain why. The error code returned in LError is 49, which apparently equates to: "Can't assign requested address". Any ideas on what the problem might be? The same code also fails on iOS (using a valid IPv6 address), so is it perhaps an Apple thing?
  12. Dave Nottage

    Cannot bind an IPv6 address on macOS

    The simplified version (as per the example) would look like this: LSockAddrIPv6.sin6_scope_id = 4; Because the index of the interface in question is 4. I've been working on some "home grown" (i.e. not Indy) code that includes retrieving the local addresses and interface indexes so that they can be used for this kind of thing (amongst others). The purpose is to have a reliable, functional means of advertising that works on all platforms, using IPv4, IPv6 and works on IPv6 only networks. I've diverged from Indy because I was having to jump through too many hoops in order to make it all work, and to simplify everything. I plan on publishing the code when it is complete.
  13. Dave Nottage

    Cannot bind an IPv6 address on macOS

    I've finally discovered the problem: The sin6_scope_id member of LSockAddrIPv6 needed to be set to the index of the interface that has the address.
  14. Dave Nottage

    Call from sim 2

    Your code does not match the Java equivalent that has been sent to you. This is the equivalent: uses Androidapi.JNI.GraphicsContentViewText, Androidapi.JNI.Net, Androidapi.Helpers; procedure TForm1.Button1Click(Sender: TObject); var MobileNumber: string; Intent: JIntent; begin MobileNumber := '*155#'; Intent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_CALL); Intent.putExtra(StringToJString('com.android.phone.extra.slot'), 1); Intent.putExtra(StringToJString('simSlot'), 1); Intent.setData(TJnet_Uri.JavaClass.parse(StringtoJString('tel:' + MobileNumber))); TAndroidHelper.Context.startActivity(Intent); end; I don't have a dual SIM device to test this. Those are not equivalent. TJIntent.JavaClass.EXTRA_PHONE_NUMBER is "android.intent.extra.PHONE_NUMBER", not "com.android.phone.extra.slot"
  15. Dave Nottage

    New section for native apps

    If you're not doing anything beyond using them while the app is in the foreground, then you probably won't have any issues. Try using them (on iOS or Android) when the app is in the background, or not running. Rollo may have been referring to them as being supported in the RTL, rather than users having to write more code to use them, such as Xcode and Android Studio developers do.
  16. Dave Nottage

    Delphi 10.3 and supported version of Android

    You can change it in AndroidManifest.Template.xml, i.e. replace %minSdkVersion% with whatever value you think should be the minimum. As per the previous replies, making this value higher will exclude as many users that have a lower version.
  17. Dave Nottage

    Simple Android App Template

    I can help particularly with this part if you're interested.
  18. Dave Nottage

    Develop with IOS emulator

    From the pic, you've created a profile for a Windows PAServer. If deploying to iOS simulator, you need to create/use one for macOS. If you are using macOS 10.15.x, it will all be for nought because the 32-bit portion of PAServer will not run. If your macOS version is earlier, read on.... You'll also need to install an iOS 10.3 simulator (using Xcode) because Delphi does not currently support later simulators. In the Xcode menu click Window > Devices and Simulators, select the Simulators tab and click the "+" button in the bottom left:
  19. Dave Nottage

    XE5 > RIO

    Thanks for the changes.. but does it work? 😉
  20. Dave Nottage

    XE5 > RIO

    If FStillImageOutput is a AVCaptureStillImageOutput, you could do this: AVCaptureStillImageOutput = interface(iOSapi.AVFoundation.AVCaptureStillImageOutput) ['{A1669519-9901-489E-BDD1-A0E697C8C6CB}'] procedure addObserver(observer: NSObject; forKeyPath: NSString; options: NSKeyValueObservingOptions; context: Pointer); cdecl; end; TAVCaptureStillImageOutput = class(TOCGenericImport<AVCaptureStillImageOutputClass, AVCaptureStillImageOutput>) end; ... TAVCaptureStillImageOutput.Wrap(FStillImageOutput).addObserver(FVideoCaptureDelegate, NSObjectToID(StrToNSStr('capturingStillImage')), NSKeyValueObservingOptionNew, NSObjectToID(FAVCaptureStillImageIsCapturingStillImageContext)); NSObjectToID comes from Macapi.Helpers
  21. Does this help? https://wiert.me/2018/06/01/unknown-function-at-tmethodimplementationintercept/
  22. Dave Nottage

    Android App Crash on Some Devices

    For this latest issue, see this link: https://stackoverflow.com/a/50779232/3164070
  23. Dave Nottage

    Android App Crash on Some Devices

    This line is interesting: 12-06 00:30:44.030: I/agamama.orderc(31926): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.arch.lifecycle.LifecycleOwner" on path: DexPathList[[zip file "/data/app/cy.com.wagamama.ordercy-qsEct8E2Xh8zg2XEtOetZg==/base.apk"],nativeLibraryDirectories=[/data/app/cy.com.wagamama.ordercy-qsEct8E2Xh8zg2XEtOetZg==/lib/arm, /data/app/cy.com.wagamama.ordercy-qsEct8E2Xh8zg2XEtOetZg==/base.apk!/lib/armeabi-v7a, /system/lib, /system/vendor/lib]] 12-06 00:30:44.030: I/agamama.orderc(31926): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.arch.lifecycle.LifecycleOwner" on path: DexPathList[[zip file "/data/app/cy.com.wagamama.ordercy-qsEct8E2Xh8zg2XEtOetZg==/base.apk"],nativeLibraryDirectories=[/data/app/cy.com.wagamama.ordercy-qsEct8E2Xh8zg2XEtOetZg==/lib/arm, /data/app/cy.com.wagamama.ordercy-qsEct8E2Xh8zg2XEtOetZg==/base.apk!/lib/armeabi-v7a, /system/lib, /system/vendor/lib]] Because android.arch.lifecycle.LifecycleOwner has long been deprecated: https://developer.android.com/reference/android/arch/lifecycle/LifecycleOwner Is there perhaps some 3rd party library you're using that's expecting this class to be present? It may be present on the devices (for compatibility) that your app works on. Not sure if this is the root cause of your problem, but it might be worth looking at.
  24. Dave Nottage

    Android App Crash on Some Devices

    Does your app perform any network calls at all? If your package is cy.com.wagamama.ordercy, the log line at 12-05 18:34:30.888 seems to indicate it is doing at least something network related, and appears to be the source of the crash.
  25. Dave Nottage

    IDETheme.ActnCtrls do not compile under 10.3.3

    Known issue: https://quality.embarcadero.com/browse/RSP-27035 Check Marco's comment on the report.
×