Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes, you should do that, since the data will still be send to your app and I believe it's always a good programming style to <code>"close" (unregister)</code> something you <code>"opened" (registered)</code>. I've written some example methods that demonstrate how to do this:</p> <p>(Note: This code would have to be placed in the class that implements <code>SensorEventListener, OnTouchListener, OnKeyListener</code>)</p> <pre><code>/** * &lt;b&gt;&lt;i&gt;public void useAccelerometer(boolean use)&lt;/i&gt;&lt;/b&gt; * &lt;br&gt; * Since: API 1 * &lt;br&gt; * &lt;br&gt; * Set if you would like to enable the use of the accelerometer. * * @param use * &lt;br&gt; * True will enable the use of the accelerometer. * &lt;br&gt; * False will disable the use of the accelerometer. * */ public void useAccelerometer(boolean use) { if(use == true) { manager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_GAME); if(this.logGameEngineInputLog == true) { gameEngineLog.d(classTAG, "Accelerometer enabled"); } } else { manager.unregisterListener(this, accelerometer); if(this.logGameEngineInputLog == true) { gameEngineLog.d(classTAG, "Accelerometer disabled"); } } } /** * &lt;b&gt;&lt;i&gt;public void useTouchscreen(boolean use)&lt;/i&gt;&lt;/b&gt; * &lt;br&gt; * Since: API 1 * &lt;br&gt; * &lt;br&gt; * Set if you would like to enable the use of the touch screen. * * @param use * &lt;br&gt; * True will enable the use of the touch screen. * &lt;br&gt; * False will disable the use of the touch screen. * */ public void useTouchscreen(boolean use) { if(use == true) { view.setOnTouchListener(this); if(this.logGameEngineInputLog == true) { gameEngineLog.d(classTAG, "Touchscreen enabled"); } } else { view.setOnTouchListener(null); if(this.logGameEngineInputLog == true) { gameEngineLog.d(classTAG, "Touchscreen disabled"); } } } /** * &lt;b&gt;&lt;i&gt;public void useKeyboard(boolean use)&lt;/i&gt;&lt;/b&gt; * &lt;br&gt; * Since: API 1 * &lt;br&gt; * &lt;br&gt; * Set if you would like to enable the use of the keyboard. * * @param use * &lt;br&gt; * True will enable the use of the keyboard. * &lt;br&gt; * False will disable the use of the keyboard. * */ public void useKeyboard(boolean use) { if(use == true) { view.setOnKeyListener(this); if(this.logGameEngineInputLog == true) { gameEngineLog.d(classTAG, "Keyboard enabled"); } } else { view.setOnKeyListener(null); if(this.logGameEngineInputLog == true) { gameEngineLog.d(classTAG, "Keyboard disabled"); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload