Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

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

@jaehyun0122

Description

@jaehyun0122

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())
                );
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions