Freepark Developers

Documentation of Freepark Smart Barrier's API

Designed with for developers

Android SDK

Please contact us on info@freepark.co for Freepark SDK file.


How to?

Add FreeApp init and terminate procedures in your application class.

public class FreeparkApplication extends Application { @Override public void onCreate() { super.onCreate(); FreeApp.init(this, <YOUR_SDK_TOKEN>); } @Override public void onTerminate() { super.onTerminate(); FreeApp.terminate(); } }

Use BleActivity as AppCompatActivity class with extends command for your Bluetooth Activity. BleActivity class will manage Bluetooth permissions automatically. (Preferred)

public class MainActivity extends BleActivity { }

You can create your Activity class if you want to manage Bluetooth permissions manually. You need to call some procedures if you will manage Bluetooth permissions by manually.

public class MainActivity extends AppCompatActivity { @Override protected void onResume() { super.onResume(); FreeLibraryBase.startScanning(); } @Override protected void onPause() { super.onPause(); FreeLibraryBase.stopScanning(); FreeLibraryBase.cleanDevices(this); } }

You can get callbacks from FreeListener interface. Just you need to set setListener procedure.

public class XFragment extends Fragment implements FreeListener { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_x, container, false); FreeLibraryBase.setListener(this); return v; } @Override public void onDestroyView() { super.onDestroyView(); FreeLibraryBase.setListener(null); } public void onDeviceChanged(List<DeviceModel> devices) { } public void onOpened(DeviceModel device) { } public void onError(DeviceModel device, FreeError error) { } }

You can find FreeError error codes below.

public enum FreeError { ConnectionError, BatteryEmpty, UnexptectedError }

Open a barrier.

@Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { DeviceModel device = parkingAdapter.getItem(i); if (device != null && device.isAvailable()) { FreeLibraryBase.connectForOpen(device); } }