-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathandroid-sdk-tutorial-100.html
154 lines (119 loc) · 6.89 KB
/
android-sdk-tutorial-100.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<title>E4 Android SDK for Developers</title>
<meta name="description" content="Develop your mobile application using the Empatica SDK for Android.">
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="highlight/styles/github.css" media="screen">
<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]-->
<!-- 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>
<script src="highlight/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body>
<div id="container">
<div class="inner">
<header>
<p><a href="/">E4 for Developers</a> E4 link SDK</p>
<h1>for Android</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 E4 link API allows you to build Android applications that can communicate with Empatica E4</p>
<p>First of all, you need to make sure your phone runs at least Android <strong> 4.4 KitKat (API level 19)</strong>. Android 6.0 or newer is recommended. This version is tested also on latest Android 9 and 10.
NOTE: 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>E4link 1.0.0 release is meant to be used with Android Studio 3.5 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>E4link has the following dependency:</p>
<li><a href="http://square.github.io/okhttp">Ok HTTP Client - version 2.7.5</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 class="swift">
allprojects {
repositories {
jcenter()
flatDir {
dirs 'libs'
}
}
}
</code>
</pre>
<li><p>Copy <code>E4link-1.0.0.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.7.5'</code>
<code> compile 'com.empatica.empalink:E4link:1.0.0@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 class="swift">
public class MainActivity extends Activity implements EmpaDataDelegate, EmpaStatusDelegate {
private EmpaDeviceManager deviceManager;
protected void onCreate(Bundle savedInstanceState) {
[...]
deviceManager = new EmpaDeviceManager(getApplicationContext(), this, this);
deviceManager.authenticateWithAPIKey("YOUR API KEY");
}
[...]
}
</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>