![Yoctopuce Yocto-GPS User Manual Download Page 116](http://html1.mh-extra.com/html/yoctopuce/yocto-gps/yocto-gps_user-manual_3415557116.webp)
public
void
onItemSelected
(
AdapterView<?> parent,
View
view,
int
pos,
long
id
)
{
serial = parent.
getItemAtPosition
(
pos
)
.
toString
()
;
}
@Override
public
void
onNothingSelected
(
AdapterView<?> arg0
)
{
}
final
Runnable
r =
new
Runnable
()
{
public
void
run
()
{
if
(
serial !=
null
)
{
YGps gps = YGps.
FindGps
(
serial
)
;
try
{
TextView state =
(
TextView
)
findViewById
(
R.
id
.
state
)
;
TextView latitude =
(
TextView
)
findViewById
(
R.
id
.
latitude
)
;
TextView longitude =
(
TextView
)
findViewById
(
R.
id
.
longitude
)
;
if
(
gps.
get_isFixed
()
== YGps.
ISFIXED_TRUE
)
{
state.
setText
(
String
.
format
(
"%d satellites"
, gps.
get_satCount
()))
;
latitude.
setText
(
gps.
get_latitude
())
;
longitude.
setText
(
gps.
get_longitude
())
;
}
else
{
state.
setText
(
"fixing..."
)
;
latitude.
setText
(
""
)
;
longitude.
setText
(
""
)
;
}
}
catch
(
YAPI_Exception e
)
{
e.
printStackTrace
()
;
}
}
handler.
postDelayed
(this
,
1000
)
;
}
}
;
}
16.6. Control of the module part
Each module can be controlled in a similar manner, you can find below a simple sample program
displaying the main parameters of the module and enabling you to activate the localization beacon.
package
com.yoctopuce.doc_examples
;
import
android.app.Activity
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.widget.AdapterView
;
import
android.widget.AdapterView.OnItemSelectedListener
;
import
android.widget.ArrayAdapter
;
import
android.widget.Spinner
;
import
android.widget.Switch
;
import
android.widget.TextView
;
import
com.yoctopuce.YoctoAPI.YAPI
;
import
com.yoctopuce.YoctoAPI.YAPI_Exception
;
import
com.yoctopuce.YoctoAPI.YModule
;
public
class
ModuleControl
extends
Activity
implements
OnItemSelectedListener
{
private
ArrayAdapter<String> aa;
private
YModule module =
null
;
@Override
public
void
onCreate
(
Bundle savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
)
;
setContentView
(
R.
layout
.
modulecontrol
)
;
Spinner my_spin =
(
Spinner
)
findViewById
(
R.
id
.
spinner1
)
;
my_spin.
setOnItemSelectedListener
(this)
;
aa =
new
ArrayAdapter<String>
(this
, android.
R
.
layout
.
simple_spinner_item
)
;
aa.
setDropDownViewResource
(
android.
R
.
layout
.
simple_spinner_dropdown_item
)
;
my_spin.
setAdapter
(
aa
)
;
}
16. Using the Yocto-GPS with Android
110
www.yoctopuce.com
Summary of Contents for Yocto-GPS
Page 1: ...Yocto GPS User s guide...
Page 2: ......
Page 6: ...22 Characteristics 557 Blueprint 559 Index 561...
Page 10: ...4 www yoctopuce com...
Page 14: ...8 www yoctopuce com...
Page 18: ...12 www yoctopuce com...
Page 22: ...16 www yoctopuce com...
Page 38: ...32 www yoctopuce com...
Page 42: ...36 www yoctopuce com...
Page 54: ...48 www yoctopuce com...
Page 72: ...66 www yoctopuce com...
Page 92: ...86 www yoctopuce com...
Page 122: ...116 www yoctopuce com...
Page 132: ...126 www yoctopuce com...
Page 564: ...22 Characteristics 558 www yoctopuce com...
Page 565: ......
Page 566: ......