-
Notifications
You must be signed in to change notification settings - Fork 14
Work with known track
Jiří M. aka Menion edited this page Mar 15, 2019
·
2 revisions
In case, you know tracks ID identificator, there are methods what to do with this track.
- Locus Map 3.9+
- method is done in SYNC over ContentProvider
- no need to have running target app
val track: Track? = ActionBasics.getTrack(context, locusVersion, trackId)
- Locus Map 3.37+
- method is done over exchange of intents between activities
- to handle exported file, no permission is needed. The exported file is provided over FileProvider API.
1. From your activity, request exported track
ActionBasics.getTrackInFormat(activity, locusVersion,
REQUEST_CODE_GET_TRACK_AS_GPX,
trackId, ActionBasics.FileFormat.GPX)
2. Handle received result in your activity
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == RC_GET_TRACK_IN_FORMAT) {
if (resultCode == Activity.RESULT_OK && data?.data != null) {
try {
val targetFile = createTempFile(System.currentTimeMillis().toString(), "gpx")
// copy data from inputStream to own file in temp directory
copy(contentResolver.openInputStream(data.data!!), targetFile)
// well ... we have now own file with exported track
...
} catch (e: Exception) {
Logger.logE(TAG, "onActivityResult($requestCode, $resultCode, $data)", e)
}
} else {
// most probably canceled
}
}
}
Request on track needs to be done in activity context. Locus Map displays progress dialog during work, so no additional UI needed on add-on side.
Request may have additional parameters in defined formatExtra
parameter. This have to be JSON formatted String with supported key/value items:
- FIT
- "mode": "activity" or "course"
- "attachments": true/false
- GPX
- "attachments": true/false
- KML
- "attachments": true/false
- "packAsKmz": true/false
- TCX
- "mode": "activity" or "course"
- "attachments": true/false
-
Basics
-
Non-API tools
-
Using API
-
Work with points
-
Work with tracks
-
Integration into Locus Map
-
Other/advanced features