![Yoctopuce Yocto-GPS Скачать руководство пользователя страница 120](http://html1.mh-extra.com/html/yoctopuce/yocto-gps/yocto-gps_user-manual_3415557120.webp)
Listing the modules
Obtaining the list of the connected modules is performed with the
YModule.yFirstModule()
function which returns the first module found. Then, you only need to call the
nextModule()
function of this object to find the following modules, and this as long as the returned value is not
null
. Below a short example listing the connected modules.
package
com.yoctopuce.doc_examples
;
import
android.app.Activity
;
import
android.os.Bundle
;
import
android.util.TypedValue
;
import
android.view.View
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
com.yoctopuce.YoctoAPI.YAPI
;
import
com.yoctopuce.YoctoAPI.YAPI_Exception
;
import
com.yoctopuce.YoctoAPI.YModule
;
public
class
Inventory
extends
Activity
{
@Override
public
void
onCreate
(
Bundle savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
)
;
setContentView
(
R.
layout
.
inventory
)
;
}
public
void
refreshInventory
(
View
view
)
{
LinearLayout layout =
(
LinearLayout
)
findViewById
(
R.
id
.
inventoryList
)
;
layout.
removeAllViews
()
;
try
{
YAPI.
UpdateDeviceList
()
;
YModule module = YModule.
FirstModule
()
;
while
(
module !=
null
)
{
String
line = module.
get_serialNumber
()
+
" ("
+ module.
get_productName
()
+
")"
;
TextView tx =
new
TextView
(this)
;
tx.
setText
(
line
)
;
tx.
setTextSize
(
TypedValue.
COMPLEX_UNIT_SP
,
20
)
;
layout.
addView
(
tx
)
;
module = module.
nextModule
()
;
}
}
catch
(
YAPI_Exception e
)
{
e.
printStackTrace
()
;
}
}
@Override
protected
void
onStart
()
{
super
.
onStart
()
;
try
{
YAPI.
EnableUSBHost
(this)
;
YAPI.
RegisterHub
(
"usb"
)
;
}
catch
(
YAPI_Exception e
)
{
e.
printStackTrace
()
;
}
refreshInventory
(
null
)
;
}
@Override
protected
void
onStop
()
{
super
.
onStop
()
;
YAPI.
FreeAPI
()
;
}
}
16. Using the Yocto-GPS with Android
114
www.yoctopuce.com
Содержание Yocto-GPS
Страница 1: ...Yocto GPS User s guide...
Страница 2: ......
Страница 6: ...22 Characteristics 557 Blueprint 559 Index 561...
Страница 10: ...4 www yoctopuce com...
Страница 14: ...8 www yoctopuce com...
Страница 18: ...12 www yoctopuce com...
Страница 22: ...16 www yoctopuce com...
Страница 38: ...32 www yoctopuce com...
Страница 42: ...36 www yoctopuce com...
Страница 54: ...48 www yoctopuce com...
Страница 72: ...66 www yoctopuce com...
Страница 92: ...86 www yoctopuce com...
Страница 122: ...116 www yoctopuce com...
Страница 132: ...126 www yoctopuce com...
Страница 159: ...20 High level API Reference On failure throws an exception or returns a negative error code www yoctopuce com 153...
Страница 564: ...22 Characteristics 558 www yoctopuce com...
Страница 565: ......
Страница 566: ......