Skip to content

Latest commit

 

History

History
18 lines (15 loc) · 1015 Bytes

getting-started.md

File metadata and controls

18 lines (15 loc) · 1015 Bytes

Getting started

created by Mateusz Chojnowski

This document contains solution some common scenarios during development of Inseye eye tracker client applications.

Binding to service

Activity currentActivity = ... // code that returns current Android Activity
android.content.ServiceConnection connection = ... // implementation of service connection object
Resources res = activity.getResources();
Intent serviceIntent = new Intent();
ComponentName component = new ComponentName(res.getString(R.string.service_package_name), res.getString(R.string.service_class_name)); // service_package_name and service_class_name are defined in this package res/values/strings.xml
serviceIntent.setComponent(component);
boolean connectedSuccessfully = currentActivity.getApplicationContext().bindService(createBindToServiceIntent(currentActivity), connection, Context.BIND_AUTO_CREATE);
if (!connectedSuccessfully)
    throw new Exception("Failed to bind to service");