
}
public
void
refreshInfo
(
View
view
)
{
DisplayModuleInfo
()
;
}
public
void
toggleBeacon
(
View
view
)
{
if
(
module ==
null
)
return
;
boolean
on =
((Switch)
view
)
.
isChecked
()
;
try
{
if
(
on
)
{
module.
setBeacon
(
YModule.
BEACON_ON
)
;
}
else
{
module.
setBeacon
(
YModule.
BEACON_OFF
)
;
}
}
catch
(
YAPI_Exception e
)
{
e.
printStackTrace
()
;
}
}
}
Each property
xxx
of the module can be read thanks to a method of type
YModule.get_xxxx()
,
and properties which are not read-only can be modified with the help of the
YModule.set_xxx()
method. For more details regarding the used functions, refer to the API chapters.
Changing the module settings
When you want to modify the settings of a module, you only need to call the corresponding
YModule.set_xxx()
function. However, this modification is performed only in the random access
memory (RAM) of the module: if the module is restarted, the modifications are lost. To memorize
them persistently, it is necessary to ask the module to save its current configuration in its permanent
memory. To do so, use the
YModule.saveToFlash()
method. Inversely, it is possible to force
the module to forget its current settings by using the
YModule.revertFromFlash()
method.
The short example below allows you to modify the logical name of a module.
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.EditText
;
import
android.widget.Spinner
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.yoctopuce.YoctoAPI.YAPI
;
import
com.yoctopuce.YoctoAPI.YAPI_Exception
;
import
com.yoctopuce.YoctoAPI.YModule
;
public
class
SaveSettings
extends
Activity
implements
OnItemSelectedListener
{
private
ArrayAdapter<String> aa;
private
YModule module =
null
;
@Override
public
void
onCreate
(
Bundle savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
)
;
setContentView
(
R.
layout
.
savesettings
)
;
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
)
;
}
17. Using the Yocto-RangeFinder with Android
110
www.yoctopuce.com
Summary of Contents for Yocto-RangeFinder
Page 1: ...Yocto RangeFinder User s guide...
Page 2: ......
Page 18: ...12 www yoctopuce com...
Page 26: ...20 www yoctopuce com...
Page 42: ...36 www yoctopuce com...
Page 70: ...gcc lyocto lm lpthread lusb 1 0 lstdc 10 Using Yocto RangeFinder with C 64 www yoctopuce com...
Page 90: ...84 www yoctopuce com...
Page 120: ...114 www yoctopuce com...
Page 130: ...124 www yoctopuce com...
Page 484: ...478 www yoctopuce com...
Page 488: ...482 www yoctopuce com...
Page 490: ...23 Characteristics 484 www yoctopuce com...
Page 491: ......
Page 492: ......