developermypos/myPOS-SDK-Android

Connect to other terminal

Closed this issue · 3 comments

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.

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

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

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"