#thiago-help
1 messages · Page 1 of 1 (latest)
hey @wise solstice
I have an issue working with Stripe Terminal, specifically in this method: Terminal.getInstance().connectBluetoothReader(
my parameters are: reader, connectionConfig, activity
my issue is in 3rd parameter
I'm working with a fragment
I'm a little bit lost
I'm sorry I know next to nothing about Android + Terminal. I'm happy to help you but I need more details about what your real issue is, more surrounding code, etc.
no worries
private fun testConnect(reader: Reader) {
val connectionConfig = ConnectionConfiguration.BluetoothConnectionConfiguration(reader.location?.id.orEmpty())
Terminal.getInstance().connectBluetoothReader(
reader,
connectionConfig,
(activity as WeakReference<MainActivity>).get(),
object : ReaderCallback {
override fun onSuccess(reader: Reader) {
runOnUiThread {
toast("connected")
}
}
override fun onFailure(e: TerminalException) {
e.printStackTrace()
runOnUiThread {
toast("error")
}
}
})
}
this is my method
I have so many doubts about the 3rd parameter
let me ask my team
@steady nimbus could you name a specific doubt you have?The call needs a reference to an Activity. If you are making the call from within a Fragment you need to structure your code to pass though a reference from the parent Activity(i.e call to https://developer.android.com/reference/androidx/fragment/app/Fragment.html#getActivity()) . Our example app has examples of the approach.
i.e. the reference is gotten at
https://github.com/stripe/stripe-terminal-android/blob/74ed451a/Example/javaapp/src/main/java/com/stripe/example/javaapp/fragment/discovery/DiscoveryFragment.java#L67
, gets held as an instance variable in https://github.com/stripe/stripe-terminal-android/blob/a31ffdc001780b7926363c7289c5f059594afd89/Example/javaapp/src/main/java/com/stripe/example/javaapp/fragment/discovery/ReaderClickListener.java#L22-L35
and is used in the call at https://github.com/stripe/stripe-terminal-android/blob/a31ffdc001780b7926363c7289c5f059594afd89/Example/javaapp/src/main/java/com/stripe/example/javaapp/fragment/discovery/ReaderClickListener.java#L58-L59
do you have this references in Kotlin?