How to Use Q1 Buttons in Applications: Difference between revisions

From wizarPOS
(Replaced content with "{{Migrating|https://smartpossdk.gitbook.io/cloudpossdk/faq/firmware/utilize-q1-buttons}}")
Tag: Replaced
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Keyboard description ==
{{Migrating|https://smartpossdk.gitbook.io/cloudpossdk/faq/firmware/utilize-q1-buttons}}
{| class="wikitable"
|-
! Key!! Value!! Description
|-
| Period || KeyEvent.KEYCODE_PERIOD || The black dot button on the right-bottom of keyboard.
|-
| QRCode|| 232 || The orange button on the middle-bottom of keyboard
|-
| Back|| KeyEvent.KEYCODE_ESCAPE|| The red X button on the left-bottom of keyboard
|-
| Scann|| 229|| The orange button on the left of the LED
|-
| Delete|| KeyEvent.KEYCODE_DEL|| The yellow triangle button on the right-top of keyboard
|-
| Enter|| KeyEvent.KEYCODE_ENTER|| The green circle button on the right-bottom of keyboard
|}
The others are digital buttons which are defined in the Android system. See android.view.KeyEvent.
 
== Scan button and QR Code button ==
The scan button and QR code button can quickly launch the scan application. If you press one of the buttons, the system will search for all the applications installed in the system and will launch the application with the scan intent-filter. If there are many applications, the system will provide a list for users to choose, and the selected application will start. The code for the scan intent-filter is as follows:
    <action android:name="android.intent.action.SCAN" />
    <category android:name="android.intent.category.DEFAULT" />
When there is no application in the system to define the scan intent-filter, pressing the scan button or QR code button will not work.
=== Sample ===
There are two ways to use the scan button and the QR code button:
* In order to use the scan button to quickly launch the scan application, the application must define the scan intent-filter in its Android manifest file. The category and the action are defined as follows:
    <activity
    android:name="com.XX.activity.MainActivity"
    android:label="@string/app_name" >
    <intent-filter>
      <!-- 设置当有人按下scan按键后调用扫描应用 -->
      <action android:name="android.intent.action.SCAN" />
      <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
    </activity>
 
* When the button is pressed, the active top task gets the key value and executes it as its logical source code. The application must override the function of onkeydown as follows:
<syntaxhighlight lang="java">
/** Key code constant: left scan key. */
public static final int KEYCODE_SCAN_LEFT        = 229;
 
/** Key code constant: right scan key. */
public static final int KEYCODE_SCAN_RIGHT        = 230;
 
/** Key code constant: qr key. */
public static final int KEYCODE_QR        = 232;
 
public boolean onKeyDown(int keyCode, KeyEvent event) {
  // listen the key code
  if (keyCode == KEYCODE_SCAN_LEFT|| keyCode ==KEYCODE_SCAN_RIGHT|| keyCode ==KEYCODE_QR) {
  //do something, for example:scanner……
    return true;
  }
  return super.onKeyDown(keyCode, event);
}
 
</syntaxhighlight >

Latest revision as of 08:39, 7 April 2024

Please visit new link of same subject:

https://smartpossdk.gitbook.io/cloudpossdk/faq/firmware/utilize-q1-buttons

We're making a move! Our site's content is migrating to a new URL, to provide you with an enhanced browsing experience. Please update your bookmarks accordingly. Thank you for your continuous support!