From wiki.ginstr.com
Jump to: navigation, search
added in Milestone 100

gn:act_removeServiceListener

Description
Action is used to remove a listener that is attached to ginstr launcher service, listeners can be widgets or variables (targets).
When listener attached to a service is removed it will stop receiving any updates from service.
i.e. if NFC listener (widget or variable) is removed from service, on scan of NFC that target will no longer receive tag content.
Action returns
void

Action signatures

[gn:act_removeServiceListener]|[serviceId;target{n}]
Parameter Description
serviceId Name of the service which will be used
  • Valid services:
    • nfc, nfc service
    • gps, gps service
    • qr, qr service (milestone 101)
target{n} target id's of the widgets which were already added as listeners to the service via gn:act_addServiceListener action

Example

On before load service is started, listener is attached. After first NFC scan we decided that action set gn:act_set should be executed and we no longer want to save NFC scan events into widget so we call gn:act_removeServiceListener. If we have 2 tags A and B, only the tag that is scanned first after coming to the screen will be stored to listener because upon scan we remove the listener so any subsequent scan will not store data to any listener.

hardware nfc data
04C357BA482780 - TAG A id
99C357BA482799 - TAG B id
initial contents
@+id/screen_nfc_input widget
screen.xml
<FrameLayout
    android:id="@+id/exampleFrame"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:visibility="gone"
    gn:act_beforeLoad="[gn:act_service]|[nfc;start;triggerActionSet,@+id/exampleFrame,gn:act_set],[gn:act_addServiceListener]|[nfc;@+id/screen_nfc_input]"
    gn:act_set="[gn:act_removeServiceListener]|[nfc;@+id/screen_nfc_input]" />

 <com.ginstr.widgets.GnEditText
    android:id="@+id/screen_nfc_input"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    gn:dataType="text"
    gn:s_sourceType="input"/>
after first nfc scan of TAG A contents
@+id/screen_nfc_input widget 04C357BA482780
after second nfc scan of TAG B contents
@+id/screen_nfc_input widget 04C357BA482780