Osmand doesn't have permission to read this file from FileProvider? In other words, does it help to allow reading in intent before calling the startActivity function:
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
(I don't know if Osmand needs write permissions. You can also try adding this: FLAG_GRANT_WRITE_URI_PERMISSION).
I also suggest carefully checking the FileProvider configuration in the pathpaths.xml file (in the xml resource directory). Maybe something like this:
<paths> <files-path path="images/" name="myimages" /> </paths>
eg. Is your file path attribute a pointer to the right directory? Are the required gpx files in this directory? ( https://developer.android.com/training/secure-file-sharing/setup-sharing.html )
Another thing to keep in mind is that the credential line in the provider item must be unique on the device. So, in this part of your AndroidManifest, make sure you replace "com.example.myapp.fileprovider" with something unique to your application:
<provider android:name="android.support.v4.content.FileProvider" android:authorities="com.example.myapp.fileprovider" android:grantUriPermissions="true" android:exported="false"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/filepaths" /> </provider>
If this does not help, I can only offer a look at the logcat output from the device to see if Osmand is writing a stack trace for this failure.
--- EDIT 07/08/2017 ---
Just to put some details into the essence of this answer: as AM proved and described in the comments below, the actual fix was to explicitly provide the necessary permissions for several specific packages on the device, repeatedly calling context.grantUriPermission in a loop, something like this:
//grant permisions for all apps that can handle given intent List<ResolveInfo> resInfoList = context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo resolveInfo : resInfoList) { String packageName = resolveInfo.activityInfo.packageName; context.grantUriPermission(packageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION); }
This approach is described in more detail here: fooobar.com/questions/23855 / ...
The need to call grantUriPermission (instead of just relying on the intention .addFlags (Intent.FLAG_GRANT_READ_URI_PERMISSION)) seems to depend on the version of the Android platform installed on the device. This is described in the problem report here: https://issuetracker.google.com/issues/37005552