English > English corner

Develop a plugin for EgiGeoZone

(1/1)

Admin:
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

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:

* "transition": "1" for entering and "0" for leaving the zone
* "zone_name": Name of the zone
* "latitude": latitude of the zone
* "longitude": longitude zone
* "device_id": An UUID, which is supposed to represent the ID of the mobile device.
* "date_iso": UTC date and time in the format "yyyy-MM-dd'T'HH: mm: ss'Z '"
* "date_device": Local date and time in the format "yyyy-MM-dd'T'HH: mm: ss"
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:

--- Code: --- <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>

--- Ende Code ---

- 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:
   
--- Code: ---    <application
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            ...

--- Ende Code ---
         

- Again: the receiver of the plugin needs to listen to the action "de.egi.geofence.geozone.plugin.EVENT":

--- Code: ---         
         <receiver android:name=".ExampleBroadcastReceiverPlugin">
              <intent-filter>
                  <action android:name="de.egi.geofence.geozone.plugin.EVENT" />
              </intent-filter>
          </receiver>

--- Ende Code ---

- An example plugin source code can be downloaded here: 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

Navigation

[0] Themen-Index

Zur normalen Ansicht wechseln