Retrieve the FAMOCO device ID

Please follow the instructions below to retrieve the FAMOCO device ID and integrate it into your application:

Step 1: Download the components :

FamocoIdIpcLib contains the AIDL implementation. Both the client and the server (in this case the famoco id service) need to have the library in their application source. The lib is distributed as .arr file and needs to be placed in the libs folder of the project.

FamocoId is the service that contains the famoco id logic, handles the client request and returns the FamocoDevice object. The application needs to be installed on the client devices.

Download the components here.

Step 2: Client implementation

Download the sample application here.

The client application needs the following steps in order to receive the FamocoDevice object :
Make sure that FamocoId (com.famoco.famocoid) is installed on the devices Add the famoco-ipc-v1.0.0.aar in the libs folder and re-sync the project

Copy the .aar file in the libs folder of the project

Starter Kit

In the module build.gradle add :

dependencies {
    ...
    compile(name:'famoco-ipc-v1.0.0', ext:'aar')
}

In the top build.gradle add :

allprojects {
    repositories {
        ...
        flatDir {
            dirs 'libs'
        }
    }
}

Bind to famoco service

 public class MainActivity extends Activity implements ServiceConnection {

    public static final String TAG = "MActivity";

    public static final String FID_PACKAGE_NAME = "com.famoco.famocoid";

    public static final String FID_SERVICE_NAME = "com.famoco.famocoid.FamocoIdService";

    private Intent mIntent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mIntent = new Intent();
        mIntent.setClassName(FID_PACKAGE_NAME, FID_SERVICE_NAME);
    }

    @Override
    protected void onResume() {
        super.onResume();
        bindToFamocoDevice();
    }

    @Override
    protected void onPause() {
        super.onPause();
        unbindService(this);
    }

    @Override
    public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
        Log.d(TAG, "onServiceConnected");
        FamocoDevice famocoDevice = null;
        try {
            famocoDevice = IRemoteInterface.Stub.asInterface(iBinder).getFamocoDevice();
        } catch (RemoteException e) {
            Log.e(TAG, e.getMessage(), e);
        }

        if (famocoDevice != null) {
            String famocoId = famocoDevice.getFamocoId();
            String model = famocoDevice.getModel();
        }
    }

    @Override
    public void onServiceDisconnected(ComponentName componentName) {}

    private void bindToFamocoDevice() {
        try {
            bindService(mIntent, this, Context.BIND_AUTO_CREATE);
        } catch (Exception e) {
            Log.e(TAG, e.getMessage(), e);
        }
    }