hackbrew
Members-
Content Count
24 -
Joined
-
Last visited
Community Reputation
1 NeutralRecent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
-
@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!
-
@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?
-
@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?
-
@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.
-
@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.
-
@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?
-
@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?
-
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?
- 1 reply
-
- android 13
- navigation buttons
-
(and 1 more)
Tagged with:
-
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?
-
Delphi 11.3, Android 13 send mapping navigation app intent
hackbrew replied to hackbrew's topic in Cross-platform
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. -
Delphi 11.3, Android 13 send mapping navigation app intent
hackbrew posted a topic in Cross-platform
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? -
@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!
-
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?
-
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>]
-
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?