Skip to content

Own function in Point screen

Jiří M. aka Menion edited this page Mar 18, 2019 · 3 revisions

Locus API offers an option to register own action in the menu of opened point screen. Thanks to this, when tapped your application receive full point object that user currently works with.

Workflow

1a. For all points: register intent-filter in your activity

<intent-filter>
    <action android:name="locus.api.android.INTENT_ITEM_POINT_TOOLS" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

1b. For geocaches only: register intent-filter for your activity

<intent-filter>
    <action android:name="locus.api.android.INTENT_ITEM_POINT_TOOLS" />
    <category android:name="android.intent.category.DEFAULT" />

    <data android:scheme="locus" />
    <data android:path="menion.android.locus/point_geocache" />
</intent-filter>

2. Handle received click in your activity as follows:

public override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    ...

    // check intent that started activity
    if (IntentHelper.isIntentPointTools(intent)) {

        // load whole track
        val pt = IntentHelper.getPointFromIntent(this, intent)
        if (pt != null) {
            // we have point, have fun
        } else {
            // problem with loading of the point
        }
    }
}