hackbrew 1 Posted June 22, 2023 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? Share this post Link to post
Rollo62 536 Posted June 23, 2023 Could this be related to changes in the intent-filter ? https://lecturepress.com/academy/object-pascal/launch-external-apps-from-delphi-android-apps/ https://medium.com/androiddevelopers/making-sense-of-intent-filters-in-android-13-8f6656903dde Share this post Link to post
hackbrew 1 Posted June 23, 2023 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. Share this post Link to post