Skip to content

App in Main menu

Jiří M. aka Menion edited this page Aug 18, 2019 · 1 revision

Last update: API 0.9.0

Locus Map has a huge list of various functions. Most of them are available in the main menu, in "menu > more" and also available for Functions panel. Your own application may register and appear on these places as well = best way how to get to users.

Workflow

1a. Register intent-filter in your activity: appear in section "Add-ons".

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

1b. Register intent-filter in your activity: appear in section "Geocaching".

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

2a. Handle received click (in case of 1a) in your activity as follows:

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

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

        // handle received intent
        IntentHelper.handleIntentMainFunction(act, intent,
                object : IntentHelper.OnIntentReceived {

                    override fun onReceived(lv: LocusUtils.LocusVersion, locGps: Location?, locMapCenter: Location?) {
                        // handle received intent with known LocusVersion and optional users locations
                    }

                    override fun onFailed() {
                        // invalid intent or any other problem
                    }
                })
    }
}

2b. Or similarly, handle received click (in case of 1b) in your activity as follows:

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

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

        // handle received intent
        IntentHelper.handleIntentMainFunctionGc(act, intent,
                object : IntentHelper.OnIntentReceived {

                    override fun onReceived(lv: LocusUtils.LocusVersion, locGps: Location?, locMapCenter: Location?) {
                        // handle received intent with known LocusVersion and optional users locations
                    }

                    override fun onFailed() {
                        // invalid intent or any other problem
                    }
                })
    }
}