wefi Analytics SDK for Android

This section describes all integration steps that are required for successful integration. You can download the wefi SDK integration guide here.

Note: wefi SDK for Android requires Android API level 16 and above.

Add JAR Files

Add the supplied jars (cauchoHessian.jar, wefiSdk.jar) to the project

Add wefi Key File to Assets

Add wefi.key file to assets directory under your application:

Warning:
If this file will not be added, wefi SDK would not start properly and “java.io.FileNotFoundException: wefi.key” error would be written to the logs.

Bind the Hosting Application to wefi

Inside your Application class, please add the following code AS THE FIRST LINES (make sure that the “super” object is the Application class itself and not a higher hierarchy class implementation of yours):

Warning:
THE FOLLOWING CODE MUST BE IN THE APPLICATION CLASS, OTHERWISE IT WILL CAUSE CRASHES DURING APPLICATION RUN TIME

@Override
public void onCreate() {
    super.onCreate();

    Context context = getApplicationContext();
    if (WfClient.isWefiEngineProcess(context)) {
        return;
    }
    WfClient.init(context);
    //Add here your code for Application.onCreate if required
    //This is done in order to prevent your code to be executed in WeFiEngine process
}

Modify the Android Manifest

Follow the required changes of your main project’s Android Manifest.xml file

Permissions

The internet permission must be present in the androidManifest.xml file of your MAIN project.

<!-- Must -->
<uses-permission android:name="android.permission.INTERNET" />

Services and Receivers

The following blocks should be added to the androidManifest.xml file of your MAIN project, under the "application" section

<service android:name="com.wefing.engine.WfEngineService" android:process=":wefiService" >
    <intent-filter>

        <!-- Change the <my app's package name> text to your real package name such as com.app.myapp -->

        <action android:name="<my app's package name>.WfEngineService" />

    </intent-filter>
</service>

<receiver android:name="com.wefing.engine.WfWatcherReceiver" android:process=":wefiService" >
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED"/>
        <action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
        <action android:name="android.intent.action.BATTERY_OKAY" />
        <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
        <action android:name="android.intent.action.USER_PRESENT" />
    </intent-filter>
</receiver>

<receiver android:name="com.wefing.engine.WfReferrerReceiver" android:exported="true" android:process=":wefiService" >
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER"/>
    </intent-filter>
</receiver>

Note:Change the <my app's package name> text to your real package name such as com.app.myapp

Integration Verification Test

When all integration steps are completed, verify there are no exceptions or errors in the logs when your application starts.
If you encounter any issues, contact us for support.