Android Question PayGate by DonManfred Service Intent Must Be Explicit

Pokmot

Member
Licensed User
Longtime User
Previous thread: https://www.b4x.com/android/forum/threads/paygate-by-donmanfred-event-question.89144/

We are a big step forward. First, I got it wrong about being an IDTECH Shuttle. The device just says "MAGTEK", that's all. It's actually the "IPS" device.

IPS Enterprise and IPS Encrypted Card Readers

The IPS devices are audio jack-connected card readers. Unlike the IDTECH Shuttle, these readers are powered by an internal battery. The IPS devices have a fast startup time and do not produce a constant tone through the audio jack.

Because the IPS devices connect through the audio port and there is no way to immediately detect the device type, you will receive a deviceConnected: event even if the user has only plugged in headphones. Since there is no activation with the IPS devices, a deviceActivated: and deviceBecameReadyForSwipe: will also be sent immediately. In order to be sure that the device is an IPS Enterprise or IPS, the PGSwipeIpsEnterprise and PGSwipeIps provide a beginTestCommunication: method you can use to attempt to communicate with the devices. Success is returned when the device has been successfully identified. This is not done by default to eliminate a delay before the device becomes active.

The permissions were set correctly, and having the "res" folder seemed to make a difference.

The error message is now

** Activity (main) Create, isFirst = true **
Error occurred on line: 40 (Main)
java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=android.intent.action.HEADSET_PLUG launchParam=MultiScreenLaunchParams { mDisplayId=0 mBaseDisplayId=0 mFlags=0 } }
at android.app.ContextImpl.validateServiceIntent(ContextImpl.java:1391)
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1428)
at android.app.ContextImpl.startService(ContextImpl.java:1404)
at android.content.ContextWrapper.startService(ContextWrapper.java:673)
at com.gdseed.mobilereader.MobileReader.<init>(Unknown Source)
at com.SafeWebServices.PaymentGateway.PGSwipeIPS.InitializeReader(PGSwipeIPS.java:30)
at com.SafeWebServices.PaymentGateway.PGSwipeController.startIPS(PGSwipeController.java:74)
at com.SafeWebServices.PaymentGateway.PGSwipeController.<init>(PGSwipeController.java:41)
at de.donmanfred.SwipecontrollerWrapper.Initialize(SwipecontrollerWrapper.java:122)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:755)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:345)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at lstw.swiper.main.afterFirstLayout(main.java:102)
at lstw.swiper.main.access$000(main.java:17)
at lstw.swiper.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)

The most relevant thread I can find is https://www.b4x.com/android/forum/threads/dealing-with-intents-and-broadcast-receiver.44465/ - but "BroadCastReceiver" is an unknown object.
 

Pokmot

Member
Licensed User
Longtime User
Aha, yes it did.

My next message is "java.lang.IllegalArgumentException: method lstw.swiper.main._swipe_ondeviceconnected argument 1 has type java.lang.String, got com.SafeWebServices.PaymentGateway.PGSwipeIPS" for:
B4X:
Sub swipe_onDeviceConnected(Device As String)

When removing the "As String" I get the following text in my label: "com.SafeWebServices.PaymentGateway.PGSwipeIPS@2b92fdd"

swipe_onDeviceDisconnected is triggered.
swipe_onDeviceConnected is triggered.
swipe_onDeviceReadyForSwipe is triggered.

swipe_onSwipedCard is NOT triggered.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Looks like we need to use the Broadcast receiver lib to listen for the broadcasts.
I can not find anything in the SwipeExample project about a Intentfilter or an Broadcast receiver...

Maybe it is important that the example exends the Activity... Don´t know.
The example starts with this line:
B4X:
public class MainActivity extends Activity implements SwipeListener {
 
Upvote 0

Pokmot

Member
Licensed User
Longtime User
Great. It seems we don't need Broadcast; after changing the version to 14 the device unplugging and plugging in is detected and seems to work fine.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
swipe_onDeviceConnected is triggered.
swipe_onDeviceReadyForSwipe is triggered.

swipe_onSwipedCard is NOT triggered.
have you tried to call
B4X:
controller.keepAlive
in one of the events? I guess, maybe the readyforswipe

the method keepAlive
B4X:
  public void keepAlive() {
      this.swipeController.getDevice().requestSwipe();
  }
will request a swipe.

From principle i would say it works as it is one listener for all the events and the other events are raised.
But i don´t know why this event does not raise.

You also can try to call the methods onClick*(view) manually to see if that does anything useful
 
Upvote 0
Top