Android Question Samsung Galaxy Store ?

MitchBu

Well-Known Member
Licensed User
Longtime User
Hi Erel,

I think my son has a Samsung Note, with the S-Pen. I can test on his device.

But if needed, I can get a used Note for more extensive tests.

If you could indeed help with implementing the S-Pen, that would open the Samsung Galaxy Store to all interested B4A developers.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Download the SDK: https://developer.samsung.com/galaxy-spen-remote/download.html
Copy the two jars to the additional libraries folder.

Run this code:
B4X:
#AdditionalJar: sdk-v1.0.0.jar
#AdditionalJar: spenremote-v1.0.1.jar
Sub Process_Globals
    Private SpenRemote As JavaObject
End Sub

Sub Globals

End Sub

Sub Activity_Create(FirstTime As Boolean)
    SpenRemote = SpenRemote.InitializeStatic("com.samsung.android.sdk.penremote.SpenRemote").RunMethod("getInstance", Null)
    Log($"Air motion: ${SpenRemote.RunMethod("isFeatureEnabled", Array(1))}"$)
    Log($"Button: ${SpenRemote.RunMethod("isFeatureEnabled", Array(0))}"$)
    Dim Callback As Object = SpenRemote.CreateEventFromUI("com.samsung.android.sdk.penremote.SpenRemote$ConnectionResultCallback", "Connection", Null)
    Dim ctxt As JavaObject
    ctxt.InitializeContext
    If SpenRemote.RunMethod("isConnected", Null) = False Then
        SpenRemote.RunMethod("connect", Array(ctxt, Callback))
    End If
End Sub

Sub Connection_Event (MethodName As String, Args() As Object) As Object
    Log(MethodName)
    Return Null
End Sub
It will crash on a non-Samsung device.
 
Upvote 0

MitchBu

Well-Known Member
Licensed User
Longtime User
Here is the result:

Runs smoothly on a Samsung phone Note 10.

Crashes on a 2016 phone chip tablet Samsung Galaxy Tab A.

I hope the Galaxy Store screens devices to know which ones are compliant to their current technology.

I have used the method described here to get the manufacturer name of the device:

That way, I run the code in Activity.Create only if I find "samsung".

And yet, a Try Catch takes care of Samsung devices that do not support S-Pen.
 
Last edited:
Upvote 0

MitchBu

Well-Known Member
Licensed User
Longtime User
MethodName: onSuccess

I was able to submit to the Galaxy app Store.

There was a last detail to add to the manifest:
<uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY"/>

I found that here:

I was then able to submit the app for review. Hopefully it will become live.
 
Upvote 0
Top