Avoid Common Mistakes When Using the S Pen Remote SDK

Ummey Habiba Bristy

Engineer, Samsung Developer Program

The S Pen is a stylus exclusive to Samsung’s Note series devices, powered by Bluetooth technology. The S Pen for Note10 devices has accelerometer and 3D gyroscope modules, which enable the stylus to detect air actions, such as single and double button presses, and directional gestures, such as up, down, left, right, clockwise circle, and counter-clockwise circle gestures. You can use the S Pen Remote SDK to map S Pen actions and gestures to features in your application.

To help you avoid making the same mistakes as I did when I was developing my application with the S Pen Remote SDK, this article describes some common implementation mistakes and their solutions.

Note: The S Pen for Note9 devices do not support the S Pen Remote SDK, but you can implement single and double button press actions for it in the application configuration file.

Mistake #1: Too many remote action activities

The S Pen Remote SDK allows one remote action activity for each application. If you define multiple remote action activities, only one activity is functional.

Figure 1: Remote action activity in the AndroidManifest.xml file

Figure 1: Remote action activity in the AndroidManifest.xml file

Mistake #2: Air actions are disabled

When you install an application on a device, such as to test it, you must manually enable air actions for the application before the application can respond to S Pen gestures.

To enable air actions for your application, on the device, go to Settings > Advanced features > S Pen > Air actions, select the application from the App actions list, and toggle the Off switch to On.

Figure 2: Enable the application in the Air actions settings

If you want the application to have air actions enabled by default, you need special permission from Samsung to add the enable_key attribute to the remote-actions element in the remote_action.xml file. To obtain permission, submit the following information about your application to spen.sec@samsung.com:

  • Application name
  • Package name
  • Information about how air actions are used in your application:
    • Does the application use the media session?
    • Does the application support background playback?
    • Describe the user scenarios in which air actions are used.

Mistake #3: Remote_action.xml configuration problems

If your application is installed on the device but does not appear in the Air actions settings, check that the remote_action.xml file content is defined correctly.

Common problems include:

  • Duplicate action priorities: The priority attribute is a mandatory part of the action element. A smaller number denotes a higher priority. Make sure each action has a unique priority number.

 Figure 3: Priority attributes in action elements

Figure 3: Priority attributes in action elements

  • Incorrectly defined action labels: In the remote_action.xml file, make sure that the label attributes of the action elements refer to resource IDs. You cannot directly implement a text string in the label attribute. You must first define the string as a resource in the strings.xml file within the values directory, then refer to the string’s resource ID in the label attribute of the action element.

Figure 4: Assign resource IDs to label strings

Figure 4: Assign resource IDs to label strings

Figure 5: Refer to resource IDs in the label attribute
Figure 5: Refer to resource IDs in the label attribute

Hope this blog helps you to integrate the S Pen Remote SDK smoothly by avoiding these mistakes. You can also study the sample application for guidance.