Skip to content
abduegal edited this page Jun 27, 2012 · 6 revisions

Bootstrap plugins are activities that can be executed when Mixare starts. There are 2 types of bootstrap plugins for each phase

  • BOOTSTRAP_PHASE_1
  • BOOTSTRAP_PHASE_2

Bootstrap plugins are executed in that order. There are 2 sample bootstrap plugins in the plugin folder: barcodescanner and splashscreen. Below is a tutorial of how to build a splashscreen plugin.

Splash screen plugin tutorial

  1. Create a new project without a main Activity. For convenience packages should be named:
    org.mixare.plugin.[pluginname]
  2. Import the mixarelib folder in the plugin directory by going to properties -> android -> library -> add (Make sure that the mixarelib project is imported in the workspace).
  3. Create an android Service class, the service class is responsible for returning an activity to the main app.
  4. Add the android service class into your application manifest. You also need to set the android:exported="true" and add the action name <action android:name="org.mixare.plugin.bootstrap1"/> in the intent filter. Note that org.mixare.plugin.bootstrap1 is the plugin category BOOTSTRAP_PHASE_1, and org.mixare.plugin.bootstrap2 is the plugin category BOOTSTRAP_PHASE_2.
        <service
            android:name=".service.ArenaSplashService"
            android:exported="true" >
            <intent-filter>
               <action android:name="org.mixare.plugin.bootstrap1"/>
               <category android:name="mixare.intent.category.BOOTSTRAP_PLUGIN"/>
            </intent-filter>
        </service>
  1. Next we are going to build the service. A bootstrap service will have to use the AIDL binder org.mixare.lib.service.IBootStrap. We also need to override the onBind(Intent intent) method
        @Override
        public IBinder onBind(Intent intent) {
            return binder;
        }
        
        private final IBootStrap.Stub binder = new IBootStrap.Stub() {
        ...
  1. A bootstrap plugin will eventually return an Activity to the Mixare core application. The following methods should be overridden
        private final String ACTIVITY_PACKAGE = "org.mixare.plugin.arenasplash";	
        private final String ACTIVITY_NAME = "org.mixare.plugin.arenasplash.ArenaSplashActivity";
        private final String PLUGIN_NAME = "arena-splash";
        private final int Z_INDEX = 0;
        public static final int ACTIVITY_REQUEST_CODE = 2118; 
        
        ...
        
        @Override
		public String getActivityName() throws RemoteException {
			return ACTIVITY_NAME; // the name of the activity created in #5: (package + classname)
		}

		@Override
		public String getActivityPackage() throws RemoteException {
			return ACTIVITY_PACKAGE; // the package of the activity created in #5
		}
		
		@Override
		public int getZIndex() throws RemoteException {
			return Z_INDEX; // when having multiple bootstrap plugins, lower z-indexes are executed sooner.
		}

		@Override
		public String getPluginName() throws RemoteException {
			return PLUGIN_NAME; // the unique name of the plugin
		}

		@Override
		public int getActivityRequestCode() throws RemoteException {
			return ACTIVITY_REQUEST_CODE; // a request code: set to 2118
		}
  1. Finally we need to create an Activity that the service can call. To end the activity and to return a result:
        Intent intent = new Intent();
        intent.putExtra("resultType", resultType); //add some data to the result
        setResult(ArenaSplashService.ACTIVITY_REQUEST_CODE, intent); //that was set to 2118 see #6
        finish();                                  //and finish it, so the main app gets the focus again.

You must return a "Splashscreen" as resultType if the activity you are using is a splashscreen, so that the main mixare app can process it. Other available plugin types are: "Datasource" (see barcode plugin)

Clone this wiki locally