-
Notifications
You must be signed in to change notification settings - Fork 3
/
android-sdk-tutorial-200-legacy.html
140 lines (109 loc) · 6.87 KB
/
android-sdk-tutorial-200-legacy.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css?2" media="screen">
<link rel="stylesheet" type="text/css" href="stylesheets/github-dark.css" media="screen">
<link rel="stylesheet" type="text/css" href="stylesheets/print.css" media="print">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<title>E4 Android SDK for Developers</title>
<meta name="description" content="Develop your mobile application using the Empatica SDK for Android.">
<!-- Favicon -->
<link rel="icon" href="//static-content1.empatica.com/YaJqf/img/favicon.png" type="image/png">
<link rel="apple-touch-icon" href="//static-content1.empatica.com/YaJqf/img/favicon.png">
<link href="//static-content1.empatica.com/YaJqf/img/favicon.png" rel="shortcut icon" type="image/x-icon">
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-25632719-2', 'auto');
ga('require', 'linkid', 'linkid.js');
ga('require', 'displayfeatures');
ga('send', 'pageview');
</script>
</head>
<body>
<div id="container">
<div class="inner">
<header>
<p><a href="/">E4 for Developers</a> > Empatica Android SDK</p>
<h1>Empatica Android SDK</h1>
</header>
<section id="main_content">
<h2>
<a id="introduction-requirements" class="anchor" href="#introduction-requirements" aria-hidden="true"></a>Introduction and requirements
</h2>
<p>The EmpaLink API allows you to build Android applications that can communicate with Empatica E4 and Empatica E3 devices.</p>
<p>First of all, you need to make sure your phone runs Android <strong> 4.4 KitKat (API level 19) or higher</strong>. Android 4.3 doesn't offer a stable enough connection, while previous versions don't support Bluetooth 4.0 (BLE) at all, and, therefore, are not <strong>compatible</strong> with the Empatica API.</p>
<p>This release is meant to be used with Android Studio 2.2 or later.</p>
<p>Once equipped with a supported phone, you need to navigate to <a href="https://www.empatica.com/connect/developer.php">Empatica Connect Developer Area</a> and request to become a developer. You will find your <strong>API</strong> key and all the download links there.</p>
<h2>
<a id="dependencies" class="anchor" href="#dependencies" aria-hidden="true"></a>Dependencies
</h2>
<p>EmpaLink has the following dependency:</p>
<li><a href="http://square.github.io/okhttp">Ok HTTP Client - version 2.5.0</a></li>
<p></p>
<h2>
<a id="installation-instructions" class="anchor" href="#installation-instructions" aria-hidden="true"></a>Installation instructions
</h2>
<ol>
<li><p>Download the SDK from <a href="https://www.empatica.com/connect/developer.php">Empatica Connect Developer Area</a></p></li>
<li><p>Open your project in Android Studio</p></li>
<li><p>Open your main build.gradle (project root) and change the trailing lines to:</p></li>
<pre>
<code>allprojects {</code>
<code>repositories {</code>
<code>jcenter()</code>
<code>flatDir {</code>
<code>dirs 'libs'</code>
<code>}</code>
<code>}</code>
<code>}</code>
</pre>
<li><p>Copy <code>empalink-2.1.aar</code> in the folder <code>libs</code> in the <code>app</code> folder (or in the folder with the name of your app). If the folder doesn't exist, create it.</p></li>
<li><p>Open your app build.gradle and, in the dependencies { ... } block, add the following line:</p>
<pre>
<code> compile 'com.squareup.okhttp:okhttp:2.5.0'</code>
<code> compile 'com.empatica.empalink:empalink:2.1@aar'</code>
</pre>
</li>
<li><p>Make sure your <code>build.gradle</code> has a <code>minSdkVersion 19</code> (or higher) line</p></li>
</ol>
<h2>
<a id="usage" class="anchor" href="#usage" aria-hidden="true"></a>Usage
</h2>
<p>First of all, you need to instantiate an <code>EmpaDeviceManager</code>, passing your application context, and references to classes implementing <code>EmpaDataDelegate</code> and <code>EmpaStatusDelegate</code>.</p>
<p>Then, you must register your <strong>API Key</strong> using the Device Manager's <code>authenticateWithAPIKey()</code> method.</p>
<p>Here's an example:</p>
<pre><code>public class MainActivity extends Activity implements EmpaDataDelegate, EmpaStatusDelegate {</code>
<code>private EmpaDeviceManager deviceManager;</code>
<code>protected void onCreate(Bundle savedInstanceState) {</code>
<code>[...]</code>
<code>deviceManager = new EmpaDeviceManager(getApplicationContext(), this, this);</code>
<code>deviceManager.authenticateWithAPIKey("YOUR API KEY");</code>
<code>}</code>
<code>[...]</code>
<code>}</code></pre>
<p>When the Device Manager is ready for use, your <code>EmpaStatusDelegate</code> will receive the <code>EmpaStatus.READY</code> value via <code>didUpdateStatus()</code>.</p>
<p>The Device Manager is now ready to scan for Empatica Devices, using: <code>deviceManager.startScanning()</code>.</p>
<p>If any devices are in range, you will receive them through the <code>EmpaStatusDelegate</code> callback <code>didDiscoverDevice(BluetoothDevice device, String deviceLabel, int rssi, boolean allowed)</code>.</p>
<p>If <code>allowed</code> is true, you can then connect to the device as follows: <code>deviceManager.connectDevice(device)</code>.</p>
<p>If the connection request is successful, the device will start streaming data, which will be transferred to your EmpaDataDelegate by invoking its callback methods.</p>
<h2>
<a id="additional-info" class="anchor" href="#additional-info" aria-hidden="true"></a>Additional info
</h2>
<p>Please check the <a href="empatica-android-sdk-javadoc.zip"> Javadoc documentation</a> for details about all the available methods.</p>
</section>
<footer>
<p>Having trouble with Empatica developer's software? <a href="mailto:[email protected]">Contact support</a> and we’ll help you sort it out.</p>
</footer>
</div>
</div>
</body>
</html>