developermypos / myPOS-SDK-Android

myPOS SDK Android enabling to integrate Apps with myPOS Card Terminals for Card Payments processing
49 stars 22 forks source link

Connect to other terminal #9

Closed emiellohr closed 3 years ago

emiellohr commented 3 years ago

I have multiple mypos terminals. When I'm connected to terminal 1 and want to switch to terminal 2, what code should I use to make the library to forget about the previously connected device.

At this moment I have to shut down terminal 1, restart the software, to be able to connect to terminal 2 and this is not desirable.

neone35 commented 3 years ago

I would also want this method of forgetting device, because different Android devices will be used with terminals on each day.

developermypos commented 3 years ago

Hello,

You can use this code to to remove last stored device: SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.remove(Utils.PREFERENCES_LAST_CONNECTED_DEVICE_ADDRESS); editor.remove(Utils.PREFERENCES_LAST_CONNECTED_DEVICE_NAME); editor.apply();

Kind regards, Stefan

emiellohr commented 3 years ago

Thanks. This works. The constants you mentioned are:

PREFERENCES_LAST_CONNECTED_DEVICE_NAME = "last_connected_device_name" PREFERENCES_LAST_CONNECTED_DEVICE_ADDRESS="last_connected_device_address"