Jump to content

hackbrew

Members
  • Content Count

    24
  • Joined

  • Last visited

Everything posted by hackbrew

  1. hackbrew

    App persistence and restoring state

    Currently, I'm working on an Android 13 FireMonkey mobile app (Delphi 11.3) with a TabControl with about four tabs. The app is grabbing JSON data from a URL and manually parses and loads the data into a FDMemTable. The app has very small data requirements (ie., single user, single table, and the JSON file would exchange only about 25 records per day containing about a dozen or so key/value pairs). Besides the memory table, I'm using an embedded database (SQLite) to store the data on device using LocalSQL features to implement database CRUD operations. My concern is persistence and restoring state if the app were to say crash/lose focus/device reset. Right now each time the app gains focus it starts from the beginning. For example, when running the app and then a call comes in on the device, my app loses its focus. When you return back to the app it starts as in the first time. I would like it if when the app restarts to remain in the same state it was before going to the background. I played around with the OnSaveState event on my main form, but it didn't behave the way I expected. For example, I send a mapping intent from my app to the default mapping app on the device for navigation. In this instance, the user temporarily leaves my app when the mapping app opens, and when closed, the user should return to my app. When I implement the OnSaveState event into my app (to read/write data to a stream) the user never returns to my app after closing the mapping app. But, if I remove the OnSaveState event, it does return back to my app, which is the desired behavior. How should persistence and restoring state be handled in an Android app?
  2. hackbrew

    App persistence and restoring state

    @Dave Nottage Yes, it appears, as best I can tell that the app is restarting. There's not too much data input on each tab or objects to deal with. So after not getting the OnSaveState to behave consitently, I've resorted to writing to a file to handle state management. Thanks!
  3. hackbrew

    App persistence and restoring state

    @programmerdelphi2k Thanks, I didn't know those settings were there. On an app close or device power off/on, what happens to data in an on-device local SQLite table?
  4. hackbrew

    App persistence and restoring state

    @programmerdelphi2k Yeah sorry, meant MSWindows. Do you know if this is a known bug in Delphi 11.3 for Android apps when shelling out to another app via intent and expecting a return to the main app upon closing?
  5. hackbrew

    App persistence and restoring state

    @programmerdelphi2k Based on what you've shown here, it looks like the OnSaveState event appears to work for a VCL application, but from what I'm seeing there are conflicts with apps running on Android OS. I can successfully launch and send data to the mobile devices mapping app using an intent from my app, but it will not return back to my app after the termination of the mapping app when I use the OnSaveState event for some reason. When I click on a navigate button from my app, I leave my app and my default mapping app opens. Upon closing/terminating the mapping app, the focus will return to my app right where I left off, which is the desired outcome. If the OnSaveState event is added to the MainForm, when I exit the mapping app, I'm returned to the Home screen, not to my app which is a problem.
  6. hackbrew

    App persistence and restoring state

    @Der schöne Günther After terminating the mapping app (Google or Waze), the focus will return to my app right where I left off, which is the desired outcome. Conversely, if the OnSaveState event is added to the MainForm and I exit the mapping app, I'm returned to the Home screen.
  7. hackbrew

    App persistence and restoring state

    @programmerdelphi2k Is the data wiped from the memory table and/or embedded database (SQLite) if the app were to say crash/lose focus/device reset?
  8. hackbrew

    App persistence and restoring state

    @Der schöne Günther Well, I have minimal code in the OnSaveState event. procedure TMainForm.FormSaveState(Sender: TObject); var W: TBinaryWriter; begin SaveState.Stream.Clear; // Save app data to restore state later. W := TBinaryWriter.Create(SaveState.Stream); try ShowMessage('FormSaveState fired'); finally W.Free; end; end; In my FormCreate event, I have: SaveState.StoragePath := TPath.GetHomePath; // Required to make this save data persistent if SaveState.Stream.Size > 0 then begin R := TBinaryReader.Create(SaveState.Stream); try ShowMessage('R: ' + R.ReadString); finally R.Free; end; end; Is there something I'm missing because I'm never seeing the "FormSaveState fired" message displayed?
  9. hackbrew

    Handling Androids Navigation buttons

    I'm working on an Android 13 FireMonkey mobile app in Delphi 11.3 which has a TabControl with four tabs. I'm having trouble with managing the Androids Navigation buttons and wondering if it's a preferred practice to hide the buttons and have the user use gestures instead. Right now, if the user presses the back button, I'm capturing the key in the OnKeyUp on my apps MainForm via if Key = vkHardwareBack then I move back a tab and/or display an exit dialog if the user is on the first tab. That works fine, but when the user taps the home or overview buttons and then comes back to my app, it starts from the beginning. What is the recommended process on how to make an Android app behave if the user taps on any of Androids Navigation buttons (back/home/overview)? Is it considered a best practice to hide them and have the user use gestures instead?
  10. I'm trying to send a user from my app to the device's default mapping app (Google Maps, Waze,...) on an Android device using an intent. It worked fine in previous Android versions (below v11), but the same code is not working in Android 13. From what I've read about permissions, it appears as though there are many more restrictions beyond Andriod 11. Anyway, when I click the Navigate button in the app, I keep getting the 'Receiver not found' message. My AndroidManifest.xml shows these locations permissions: android:targetSdkVersion="32" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> Here's my code for the Navigate button click event: procedure TMainForm.NavigateBtnClick(Sender: TObject); var {$IFDEF ANDROID} Intent: JIntent; //Declares the intent object {$ENDIF} LGoogleMapsURL: String; begin // Populate a string to send to Mapping app LGoogleMapsURL:= 'google.navigation:q=37.422219,-122.08364&mode=d'; {$IFDEF MSWINDOWS} WebBrowser1.Navigate(LGoogleMapsURL); {$ENDIF} {$IFDEF ANDROID} Intent := TJIntent.Create; Intent.setData(StrToJURI(LGoogleMapsURL)); Intent.setAction(TJIntent.JavaClass.ACTION_VIEW); Intent.putExtra(TJIntent.JavaClass.EXTRA_TEXT, StringToJString(LGoogleMapsURL)); if MainActivity.getPackageManager.queryIntentActivities(Intent, TJPackageManager.JavaClass.MATCH_DEFAULT_ONLY).size > 0 then begin MainActivity.startActivity(Intent); end else ShowMessage('Receiver not found'); {$ENDIF} end; Is this no longer valid for Android 13?
  11. Credit goes to @Dave Nottage for assistance. I had to modify the AndroidManifest.template.xml, to change the <queries> tag to: <queries> <%queries-child-elements%> <package android:name="com.google.android.apps.maps" /> </queries> In my OnClick event I added: URI := TJnet_Uri.JavaClass.parse(StringToJString('google.navigation:q=37.422219,-122.08364&mode=d')); Intent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_VIEW, URI); Intent.setPackage(StringToJString('com.google.android.apps.maps')); if Intent.resolveActivity(TAndroidHelper.Context.getPackageManager) <> nil then TAndroidHelper.Context.startActivity(Intent); That works great for the Google mapping app, but I'd like a way to call the user's preferred/default mapping app on the device.
  12. I'm running Delphi 10.4.2 and trying to add in Android 13 (API level 33) via SDK Manager. When I go to Tools-->Options-->Deployment-SDK Manager and attempt to modify the path for SDK Base Path to point to the new Android (API level 33) SDK I get an Invalid Path. My current paths in Delphi SDK Manager are: SDK Base Path: C:\Users\Public\Documents\Embarcadero\Studio\21.0\CatalogRepository\AndroidSDK-2525-21.0.37889.9797 NDK Base Path: C:\Users\Public\Documents\Embarcadero\Studio\21.0\CatalogRepository\AndroidNDK-21-21.0.37889.9797\android-ndk-r21 I tried pointing to this path showing in my Android Studio SDK Manager C:\Users\standard user\AppData\Local\Android\Sdk\build-tools\33.0.2, and just C:\Users\standard user\AppData\Local\Android\Sdk, which is where my Android Studio files reside, but I keep getting the invalid path error. In Delphi, I noticed on the Java tab of SDK Manager that the Jarsigner path shows C:\Program Files\AdoptOpenJDK\jdk-8.0.242.08-hotspot\bin\JarSigner.exe. I did read that Delphi 10.4.2 is using Jarsigner instead of APKSigner, which is required for APKs with a target SDK of 30 or higher. A thread mentioned that API level 30 or above must now be also signed using APK Signature Scheme v2 or higher. What do I need to do to get this working properly?
  13. hackbrew

    Delphi 10.4.2 add support for Android 13

    @programmerdelphi2k I really appreciate all the time you took with me to get me where my system is now, and I learned a lot about manually updating Android in the process. Thank you! I finally upgraded my system to 11.3 and I have my apps working on Android 13. There are some new problems (change in permissions, sending an intent to mapping software not working, storing files, and keyboard issues when devices are using different virtual keyboards) to work through, but I'm slowly working my way forward. Thanks again!
  14. hackbrew

    Delphi 10.4.2 add support for Android 13

    I got a long Terms and Conditions EULA, so it must have worked. It ran when I typed the command: sdkmanager --update --sdk_root=>sdkmanager --sdk_root=C:\AndroidSDKs\AndroidSDK25\ It appeared to update to: repositories.cfg could not be loaded. Installed packages: Path | Version | Description | Location ------- | ------- | ------- | ------- build-tools;29.0.3 | 29.0.3 | Android SDK Build-Tools 29.0.3 | build-tools\29.0.3\ platform-tools | 34.0.3 | Android SDK Platform-Tools | platform-tools\ platforms;android-29 | 5 | Android SDK Platform 29 | platforms\android-29\ tools | 25.2.5 | Android SDK Tools 25.2.5 | tools\ I updated the paths in Delphi SDK Manager and tried to compile/run an App. I got 541 errors which I think are all now coming from AndroidNDK like this : [DCC Error] E2597 C:\Users\Public\Documents\Embarcadero\Studio\21.0\CatalogRepository\AndroidNDK-21-21.0.40680.4203\android-ndk-r21\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld.exe: error: c:\program files (x86)\embarcadero\studio\21.0\lib\Android64\debug\SysInit.o: incompatible target When you say, "Embarcadero dont use the last updates, then use the expected only.", what version of the NDK should I download from Google?
  15. hackbrew

    Delphi 10.4.2 add support for Android 13

    It didn't like it >sdkmanager --sdk_root=C:\AndroidSDKs\AndroidSDK25 Usage: sdkmanager [--uninstall] [<common args>] \ [--package_file <package-file>] [<packages>...] sdkmanager --update [<common args>] sdkmanager --list [<common args>]
  16. hackbrew

    Delphi 10.4.2 add support for Android 13

    So at the command line just run sdkmanager C:\AndroidSDKs\AndroidSDK25 and it will install or do I need the parameters sdkmanager --sdk_root=C:\AndroidSDKs\AndroidSDK25?
  17. hackbrew

    Delphi 10.4.2 add support for Android 13

    @programmerdelphi2kOkay, progress. I created easier folder names as you suggested, and copied the folders/files from Delphi SDK install there. I then executed: C:\AndroidSDKs\AndroidSDK25\tools\bin>sdkmanager --list Warning: File C:\Users\myAdmin\.android\repositories.cfg could not be loaded. Installed packages: Path | Version | Description | Location ------- | ------- | ------- | ------- build-tools;29.0.3 | 29.0.3 | Android SDK Build-Tools 29.0.3 | build-tools\29.0.3\ platform-tools | 29.0.6 | Android SDK Platform-Tools 29.0.6 | platform-tools\ platforms;android-29 | 4 | Android SDK Platform 29, rev 4 | platforms\android-29\ tools | 25.2.5 | Android SDK Tools 25.2.5 | tools\ Available Packages: // About 100 lines of available stuff loaded here Available Updates: ID | Installed | Available ------- | ------- | ------- platform-tools | 29.0.6 | 34.0.3 platforms;android-29 | 4 | 5 done I got the warning that repositories.cfg could not be loaded. That may be a permissions issue as that folder is under the Admin user of this workstation I'm running on. Should that be copied somewhere else? Am I reading it correctly, that it will load android-29 and not android-33 if I update? I'm trying to target Android 13.
  18. hackbrew

    Delphi 10.4.2 add support for Android 13

    @programmerdelphi2k Okay, I removed Android Studio and downloaded the last version of "cmdline-tools" from Android Studio official site. I created a new empty folder named C:\Users\Public\Documents\Embarcadero\Studio\21.0\CatalogRepository\AndroidSDK-33.0.3. I then extracted the zip and it made a cmdline-tools folder in my new AndroidSDK-33.0.3 folder. At this point, that's all (cmdline-tools) that's in that folder. Now, from the Windows command line I will execute cd C:\Users\Public\Documents\Embarcadero\Studio\21.0\CatalogRepository\AndroidSDK-33.0.3\cmdline-tools\bin> to get to the proper folder. Next, do I proceed with the first command you recommended (sdkmanager set REPO_OS_OVERRIDE=windows) or do I first need separate SDK and NDK folders? If I need the folders, should I just copy the folders (AndroidSDK-2525-21.0.37889.9797) from what was created when I installed Delphi (seen here)? 
  19. hackbrew

    Delphi 10.4.2 add support for Android 13

    @programmerdelphi2k @Dave Nottage Update: I ran adb version and this is what it showed: Android Debug Bridge version 1.0.41 Version 33.0.3-8952118. Since in Delphi SDK Manager, I was pointed to an AndroidSDK-33.0.2 folder, I created a C:\Users\Public\Documents\Embarcadero\Studio\21.0\CatalogRepository\AndroidSDK-33.0.3\ folder and copied what I thought were the required files there. I then updated my paths in Delphi, but still no luck. At this point, I'm not sure if I'm close or not, but I think I'm making it way too complicated, based on having multiple versions in multiple places. With that said, I thinking of starting over to simplify the process. If you agree, would you recommend that I uninstall Android Studio (which I don't really use) and move forward by running from the command-line with SDKManager.BAT to update?
  20. hackbrew

    Delphi 10.4.2 add support for Android 13

    I do notice that in the path "C:\Users\Public\Documents\Embarcadero\Studio\21.0\CatalogRepository\AndroidSDK-33.0.2\platforms" besides the folder that I'm pointing to (android-33), there is also a folder named "android-33-ext5". The paths defined in Delphi look correct to me. Here are the paths:
  21. hackbrew

    Delphi 10.4.2 add support for Android 13

    Okay, thank you. Some progress. I added all the paths in the Delphi SDK Manager and Delphi accepted them, but it named the platform Android SDK 26.1.1 when doing both 32 and 64-bit. I'm not sure why? I then tried to build a simple test program. I added the new platform and when I go to build it returns a long path "[Exec Error] The command "PATH \bin;C:\Program Files..." an exited with code 9009 error. Is this because the building script is not compatible with the SDK that Delphi installed? I get the same error with the device connected or not.
  22. hackbrew

    Delphi 10.4.2 add support for Android 13

    @Dave Nottage These folders were copied during the Install of Android Studio. Now here's what's in my C:\Users\mh standard\AppData\Local\Android\Sdk folder : I created a new folder C:\Users\Public\Documents\Embarcadero\Studio\21.0\CatalogRepository\AndroidSDK-33.0.2 and copied in the build-tools, platforms, platform-tools, and tools folders. Assuming I need to modify the paths in Delphi SDK Manager. Are there any other files required?
  23. hackbrew

    Delphi 10.4.2 add support for Android 13

    @programmerdelphi2k Okay. So following your other thread on the forum I have located the sdkmanager.bat at C:\Users\mh standard\AppData\Local\Android\Sdk\tools\bin. So that I'm following you correctly, for the first of the 3 command line commands I tried to run: sdkmanager.bat --sdk_root=C:\Users\mh standard\AppData\Local\Android\Sdk "build-tools;33.0.2" "cmdline-tools;v5". When run that gave me the message below: Warning: Failed to find package standard\AppData\Local\Android\Sdk [=== ] 10% Computing updates...
  24. I have set up some test databases in AWS RDS (MySQL, PostgreSQL, and MariaDB). Assuming I have the proper user permissions for basic CRUD operations, am I able to connect to the databases with Delphi Professional (v10.4)? If so, what if any advantage would upgrading to Delphi Enterprise provide me for this task?
×