EgiGeoZone Forum

English => English corner => Thema gestartet von: Admin am 07.10.2015, 08:23:14

Titel: Develop a plugin for EgiGeoZone
Beitrag von: Admin am 07.10.2015, 08:23:14
With version 2.0.4 EgiGeoZone introduced the ability to handle plugins. Here is a short description how to make such a plugin.

This information is further maintained under http://egigeozone.de/developer/default.html (http://egigeozone.de/developer/default.html)

Recipe to develop a EgiGeoZone plugin

- First, create a new Android project and then create at least one Activity for the plug-in configuration. The plugin itself is responsible for saving the configuration. You can, for example, save the configuration in the SharedPreferences or in your database.

- The project must also create a BroadcastReceiver or better a WakefulBroadcastReceiver which will receive an Intent. The BroadcastReceiver needs to listen to the action "de.egi.geofence.geozone.plugin.EVENT". The best choice is that the BroadcastReceiver will start a service, which then does the plugin work.

- The EgiGeoZone app Intent provides the following parameters to the plugins:

If available to the main app, new parameters can be requested.

- Once an EgiGeoZone event is about to broadcast to the plugins, then the EgiGeoZone app checks, if the plugins have an Intent-Filter with an action "de.egi.geofence.geozone.GETPLUGINS".  Only to this plugins the app will broadcast his Intent.

Example of this part in the manifest file:
<activity
android:name=".ExamplePluginMain"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="de.egi.geofence.geozone.GETPLUGINS" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

- Also you need the following permission, which keeps the processor from sleeping when a message is received in the Broadcastreceiver:
   <uses-permission android:name="android.permission.WAKE_LOCK" />

- Under the Administration section the EgiGeoZone app shows a list of the found plugins on the device. With a tap on one of the plugins, the main activity of the plugin can be invoked. So it is a good idea to have the application label and application icon referenced in the manifest file:
       <application
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            ...
         

- Again: the receiver of the plugin needs to listen to the action "de.egi.geofence.geozone.plugin.EVENT":
         
         <receiver android:name=".ExampleBroadcastReceiverPlugin">
              <intent-filter>
                  <action android:name="de.egi.geofence.geozone.plugin.EVENT" />
              </intent-filter>
          </receiver>

- An example plugin source code can be downloaded here: http://www.egigeozone.de/download/ExamplePluginSource.zip (http://www.egigeozone.de/download/ExamplePluginSource.zip)
- The app can also be found in the Google Play Store: https://play.google.com/store/apps/details?id=de.egi.geofence.geozone.plugin.example (https://play.google.com/store/apps/details?id=de.egi.geofence.geozone.plugin.example)