Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BlueTooth device name have changed When i use nearby connections api startAdvertising() function #304

Open
jaehyun0122 opened this issue Mar 12, 2024 · 0 comments

Comments

@jaehyun0122
Copy link

jaehyun0122 commented Mar 12, 2024

i tried to run NearbyConnectionsWalkieTalkie
When i run the startAdvertising function of the nearby connection API, the Bluetooth device name displayed on other devices will change.
When i run the startAdvertising function, the symptom appears, and when i stopAdvertising, the desired device name returns.
I don't know the cause.
The DiscoveredEndpointInfo.endpointName value in the onEndPointFound function is ",BrailleSense6", which is the value I want.

Is there a way to prevent the Bluetooth device name from changing?
Before startAdvertising() :
expected

after startAdvertising() :
changed

I ran the following code:

public class NearbyConnectionUI extends HanSystemUI {
private ConnectionsClient mConnectionsClient;

private void startAdvertising(){
        mConnectionsClient
                .startAdvertising(
                        Settings.Secure.getString(mContext.getContentResolver(), "bluetooth_name"),
                        BuildConfig.APPLICATION_ID, // serviceID
                        new ConnectionLifecycleCallback() {

                            @Override
                            public void onConnectionInitiated(@NonNull String endpointID, @NonNull ConnectionInfo connectionInfo) {
                                Log.d(TAG, "onConnectionInitiated: endpointID : " + endpointID + "endpointName : " + connectionInfo.getEndpointName());

                                mNearbyConfirmDlg.setDeviceName(connectionInfo.getEndpointName());
                                mNearbyConfirmDlg.setConnectionConfirmInterface(result -> {
                                    if ("ok".equals(result)) {
                                        acceptConnection(endpointID);
                                    } else {

                                    }
                                });

                                mNearbyConfirmDlg.show();
                            }

                            @Override
                            public void onConnectionResult(@NonNull String endpointID, @NonNull ConnectionResolution connectionsResult) {
                                Log.d(TAG, "onConnectionResult: endpointID : " + endpointID + ", result : " + connectionsResult.getStatus().getStatusCode());
                                if (connectionsResult.getStatus().isSuccess()) {

                                }
                            }

                            @Override
                            public void onDisconnected(@NonNull String endpointID) {
                                Log.d(TAG, "onDisconnected: endpointID : " + endpointID);
                            }
                        },
                        new AdvertisingOptions.Builder().setStrategy(Strategy.P2P_STAR).build()
                )
                .addOnSuccessListener(
                        unusedResult ->
                                Log.d(TAG, "advertising success. endpointName : " +
                                        Settings.Global.getString(mContext.getContentResolver(), Settings.Global.DEVICE_NAME))
                )
                .addOnFailureListener(
                        exception ->
                                Log.d(TAG, "advertising fail. exception : " + exception.getMessage())
                );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant