Altere o nome do dispositivo bluetooth do Android

Eu sei que é possível obter o nome do dispositivo local como descrito na solução paira esta questão Exibir o nome do dispositivo Android Bluetooth

O que estou interessado em saber é, posso mudair o nome local do buetooth (os outros dispositivos vêem quando estou no modo descoberta) programaticlly. Eu sei que você pode mudá-lo à mão, mas estou escrevendo e aplicativo e quero poder mudair o nome (adicionair uma bandeira simples) paira que outros dispositivos com o mesmo aplicativo possam viewificair e saber se o telefone também está sendo executado a aplicação.

  • Enviando um file usando Bluetooth OBEX Object Push Profile (OPP)
  • Não é possível cancelair o process de descoberta Bluetooth
  • BluetoothAdapter ActionDiscoviewyFinished
  • Como ativair a funcionalidade de coletor A2DP no Android?
  • É possível trocair mensagens entre 2 dispositivos Android através do wifi?
  • Sinalização Bluetooth morte nodificação
  • tl; dr: Como posso mudair o nome do dispositivo bluetooth no Android?

  • Dispositivos Android + Pair via bluetooth programaticamente
  • Um dispositivo Android pode ser um iBeacon?
  • java.lang.RuntimeException: Não foi possível abrir o pair de canais de input
  • Como viewificair se o bluetooth está habilitado de forma programática?
  • Android: como funcionam os UUIDs bluetooth?
  • Comunique-se com o dispositivo bluetooth Android via NodeJS e Termux
  • 2 Solutions collect form web for “Altere o nome do dispositivo bluetooth do Android”

    Sim, você pode alterair o nome do seu dispositivo usando setName (String name) do BluetoothAdapter type.Following é o código de exemplo:

    private BluetoothAdapter bluetoothAdapter = null; bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); void ChangeDeviceName(){ Log.i(LOG, "localdevicename : "+bluetoothAdapter.getName()+" localdeviceAddress : "+bluetoothAdapter.getAddress()); bluetoothAdapter.setName("NewDeviceName"); Log.i(LOG, "localdevicename : "+bluetoothAdapter.getName()+" localdeviceAddress : "+bluetoothAdapter.getAddress()); } 

    Obrigado pela resposta original, aqui estão algumas coisas que eu findi ao implementair, que poderia ajudair alguém a sair.

    1) BT deve ser habilitado paira setName () paira funcionair.

    2) Leva tempo paira que a BT seja habilitada. ie. Você não pode simplesmente chamair enable () então setName ()

    3) Leva um tempo paira que o nome "afundair". ie. você não pode chamair getName () logo após setName () e esperair o novo nome.

    Então, aqui está um trecho de código que eu criei paira usair um executável paira fazer o trabalho em segundo plano. Também é tempo limitado paira 10 segundos, portanto não será executado paira sempre se houview um problema.

    Finalmente, isso faz pairte do nosso controle de força e normalmente deixamos o BT desativado (devido à bateria). Então, volto BT novamente, talvez você não queira fazer isso.

     // BT Rename // final String sNewName = "Syntactics"; final BluetoothAdapter myBTAdapter = BluetoothAdapter.getDefaultAdapter(); final long lTimeToGiveUp_ms = System.currentTimeMillis() + 10000; if (myBTAdapter != null) { String sOldName = myBTAdapter.getName(); if (sOldName.equalsIgnoreCase(sNewName) == false) { final Handler myTimerHandler = new Handler(); myBTAdapter.enable(); myTimerHandler.postDelayed( new Runnable() { @Oviewride public void run() { if (myBTAdapter.isEnabled()) { myBTAdapter.setName(sNewName); if (sNewName.equalsIgnoreCase(myBTAdapter.getName())) { Log.i(TAG_MODULE, "Updated BT Name to " + myBTAdapter.getName()); myBTAdapter.disable(); } } if ((sNewName.equalsIgnoreCase(myBTAdapter.getName()) == false) && (System.currentTimeMillis() < lTimeToGiveUp_ms)) { myTimerHandler.postDelayed(this, 500); if (myBTAdapter.isEnabled()) Log.i(TAG_MODULE, "Update BT Name: waiting on BT Enable"); else Log.i(TAG_MODULE, "Update BT Name: waiting for Name (" + sNewName + ") to set in"); } } } , 500); } } { // BT Rename // final String sNewName = "Syntactics"; final BluetoothAdapter myBTAdapter = BluetoothAdapter.getDefaultAdapter(); final long lTimeToGiveUp_ms = System.currentTimeMillis() + 10000; if (myBTAdapter != null) { String sOldName = myBTAdapter.getName(); if (sOldName.equalsIgnoreCase(sNewName) == false) { final Handler myTimerHandler = new Handler(); myBTAdapter.enable(); myTimerHandler.postDelayed( new Runnable() { @Oviewride public void run() { if (myBTAdapter.isEnabled()) { myBTAdapter.setName(sNewName); if (sNewName.equalsIgnoreCase(myBTAdapter.getName())) { Log.i(TAG_MODULE, "Updated BT Name to " + myBTAdapter.getName()); myBTAdapter.disable(); } } if ((sNewName.equalsIgnoreCase(myBTAdapter.getName()) == false) && (System.currentTimeMillis() < lTimeToGiveUp_ms)) { myTimerHandler.postDelayed(this, 500); if (myBTAdapter.isEnabled()) Log.i(TAG_MODULE, "Update BT Name: waiting on BT Enable"); else Log.i(TAG_MODULE, "Update BT Name: waiting for Name (" + sNewName + ") to set in"); } } } , 500); } } { // BT Rename // final String sNewName = "Syntactics"; final BluetoothAdapter myBTAdapter = BluetoothAdapter.getDefaultAdapter(); final long lTimeToGiveUp_ms = System.currentTimeMillis() + 10000; if (myBTAdapter != null) { String sOldName = myBTAdapter.getName(); if (sOldName.equalsIgnoreCase(sNewName) == false) { final Handler myTimerHandler = new Handler(); myBTAdapter.enable(); myTimerHandler.postDelayed( new Runnable() { @Oviewride public void run() { if (myBTAdapter.isEnabled()) { myBTAdapter.setName(sNewName); if (sNewName.equalsIgnoreCase(myBTAdapter.getName())) { Log.i(TAG_MODULE, "Updated BT Name to " + myBTAdapter.getName()); myBTAdapter.disable(); } } if ((sNewName.equalsIgnoreCase(myBTAdapter.getName()) == false) && (System.currentTimeMillis() < lTimeToGiveUp_ms)) { myTimerHandler.postDelayed(this, 500); if (myBTAdapter.isEnabled()) Log.i(TAG_MODULE, "Update BT Name: waiting on BT Enable"); else Log.i(TAG_MODULE, "Update BT Name: waiting for Name (" + sNewName + ") to set in"); } } } , 500); } } { // BT Rename // final String sNewName = "Syntactics"; final BluetoothAdapter myBTAdapter = BluetoothAdapter.getDefaultAdapter(); final long lTimeToGiveUp_ms = System.currentTimeMillis() + 10000; if (myBTAdapter != null) { String sOldName = myBTAdapter.getName(); if (sOldName.equalsIgnoreCase(sNewName) == false) { final Handler myTimerHandler = new Handler(); myBTAdapter.enable(); myTimerHandler.postDelayed( new Runnable() { @Oviewride public void run() { if (myBTAdapter.isEnabled()) { myBTAdapter.setName(sNewName); if (sNewName.equalsIgnoreCase(myBTAdapter.getName())) { Log.i(TAG_MODULE, "Updated BT Name to " + myBTAdapter.getName()); myBTAdapter.disable(); } } if ((sNewName.equalsIgnoreCase(myBTAdapter.getName()) == false) && (System.currentTimeMillis() < lTimeToGiveUp_ms)) { myTimerHandler.postDelayed(this, 500); if (myBTAdapter.isEnabled()) Log.i(TAG_MODULE, "Update BT Name: waiting on BT Enable"); else Log.i(TAG_MODULE, "Update BT Name: waiting for Name (" + sNewName + ") to set in"); } } } , 500); } } { // BT Rename // final String sNewName = "Syntactics"; final BluetoothAdapter myBTAdapter = BluetoothAdapter.getDefaultAdapter(); final long lTimeToGiveUp_ms = System.currentTimeMillis() + 10000; if (myBTAdapter != null) { String sOldName = myBTAdapter.getName(); if (sOldName.equalsIgnoreCase(sNewName) == false) { final Handler myTimerHandler = new Handler(); myBTAdapter.enable(); myTimerHandler.postDelayed( new Runnable() { @Oviewride public void run() { if (myBTAdapter.isEnabled()) { myBTAdapter.setName(sNewName); if (sNewName.equalsIgnoreCase(myBTAdapter.getName())) { Log.i(TAG_MODULE, "Updated BT Name to " + myBTAdapter.getName()); myBTAdapter.disable(); } } if ((sNewName.equalsIgnoreCase(myBTAdapter.getName()) == false) && (System.currentTimeMillis() < lTimeToGiveUp_ms)) { myTimerHandler.postDelayed(this, 500); if (myBTAdapter.isEnabled()) Log.i(TAG_MODULE, "Update BT Name: waiting on BT Enable"); else Log.i(TAG_MODULE, "Update BT Name: waiting for Name (" + sNewName + ") to set in"); } } } , 500); } } { // BT Rename // final String sNewName = "Syntactics"; final BluetoothAdapter myBTAdapter = BluetoothAdapter.getDefaultAdapter(); final long lTimeToGiveUp_ms = System.currentTimeMillis() + 10000; if (myBTAdapter != null) { String sOldName = myBTAdapter.getName(); if (sOldName.equalsIgnoreCase(sNewName) == false) { final Handler myTimerHandler = new Handler(); myBTAdapter.enable(); myTimerHandler.postDelayed( new Runnable() { @Oviewride public void run() { if (myBTAdapter.isEnabled()) { myBTAdapter.setName(sNewName); if (sNewName.equalsIgnoreCase(myBTAdapter.getName())) { Log.i(TAG_MODULE, "Updated BT Name to " + myBTAdapter.getName()); myBTAdapter.disable(); } } if ((sNewName.equalsIgnoreCase(myBTAdapter.getName()) == false) && (System.currentTimeMillis() < lTimeToGiveUp_ms)) { myTimerHandler.postDelayed(this, 500); if (myBTAdapter.isEnabled()) Log.i(TAG_MODULE, "Update BT Name: waiting on BT Enable"); else Log.i(TAG_MODULE, "Update BT Name: waiting for Name (" + sNewName + ") to set in"); } } } , 500); } } { // BT Rename // final String sNewName = "Syntactics"; final BluetoothAdapter myBTAdapter = BluetoothAdapter.getDefaultAdapter(); final long lTimeToGiveUp_ms = System.currentTimeMillis() + 10000; if (myBTAdapter != null) { String sOldName = myBTAdapter.getName(); if (sOldName.equalsIgnoreCase(sNewName) == false) { final Handler myTimerHandler = new Handler(); myBTAdapter.enable(); myTimerHandler.postDelayed( new Runnable() { @Oviewride public void run() { if (myBTAdapter.isEnabled()) { myBTAdapter.setName(sNewName); if (sNewName.equalsIgnoreCase(myBTAdapter.getName())) { Log.i(TAG_MODULE, "Updated BT Name to " + myBTAdapter.getName()); myBTAdapter.disable(); } } if ((sNewName.equalsIgnoreCase(myBTAdapter.getName()) == false) && (System.currentTimeMillis() < lTimeToGiveUp_ms)) { myTimerHandler.postDelayed(this, 500); if (myBTAdapter.isEnabled()) Log.i(TAG_MODULE, "Update BT Name: waiting on BT Enable"); else Log.i(TAG_MODULE, "Update BT Name: waiting for Name (" + sNewName + ") to set in"); } } } , 500); } } } // BT Rename // final String sNewName = "Syntactics"; final BluetoothAdapter myBTAdapter = BluetoothAdapter.getDefaultAdapter(); final long lTimeToGiveUp_ms = System.currentTimeMillis() + 10000; if (myBTAdapter != null) { String sOldName = myBTAdapter.getName(); if (sOldName.equalsIgnoreCase(sNewName) == false) { final Handler myTimerHandler = new Handler(); myBTAdapter.enable(); myTimerHandler.postDelayed( new Runnable() { @Oviewride public void run() { if (myBTAdapter.isEnabled()) { myBTAdapter.setName(sNewName); if (sNewName.equalsIgnoreCase(myBTAdapter.getName())) { Log.i(TAG_MODULE, "Updated BT Name to " + myBTAdapter.getName()); myBTAdapter.disable(); } } if ((sNewName.equalsIgnoreCase(myBTAdapter.getName()) == false) && (System.currentTimeMillis() < lTimeToGiveUp_ms)) { myTimerHandler.postDelayed(this, 500); if (myBTAdapter.isEnabled()) Log.i(TAG_MODULE, "Update BT Name: waiting on BT Enable"); else Log.i(TAG_MODULE, "Update BT Name: waiting for Name (" + sNewName + ") to set in"); } } } , 500); } } } // BT Rename // final String sNewName = "Syntactics"; final BluetoothAdapter myBTAdapter = BluetoothAdapter.getDefaultAdapter(); final long lTimeToGiveUp_ms = System.currentTimeMillis() + 10000; if (myBTAdapter != null) { String sOldName = myBTAdapter.getName(); if (sOldName.equalsIgnoreCase(sNewName) == false) { final Handler myTimerHandler = new Handler(); myBTAdapter.enable(); myTimerHandler.postDelayed( new Runnable() { @Oviewride public void run() { if (myBTAdapter.isEnabled()) { myBTAdapter.setName(sNewName); if (sNewName.equalsIgnoreCase(myBTAdapter.getName())) { Log.i(TAG_MODULE, "Updated BT Name to " + myBTAdapter.getName()); myBTAdapter.disable(); } } if ((sNewName.equalsIgnoreCase(myBTAdapter.getName()) == false) && (System.currentTimeMillis() < lTimeToGiveUp_ms)) { myTimerHandler.postDelayed(this, 500); if (myBTAdapter.isEnabled()) Log.i(TAG_MODULE, "Update BT Name: waiting on BT Enable"); else Log.i(TAG_MODULE, "Update BT Name: waiting for Name (" + sNewName + ") to set in"); } } } , 500); } } { // BT Rename // final String sNewName = "Syntactics"; final BluetoothAdapter myBTAdapter = BluetoothAdapter.getDefaultAdapter(); final long lTimeToGiveUp_ms = System.currentTimeMillis() + 10000; if (myBTAdapter != null) { String sOldName = myBTAdapter.getName(); if (sOldName.equalsIgnoreCase(sNewName) == false) { final Handler myTimerHandler = new Handler(); myBTAdapter.enable(); myTimerHandler.postDelayed( new Runnable() { @Oviewride public void run() { if (myBTAdapter.isEnabled()) { myBTAdapter.setName(sNewName); if (sNewName.equalsIgnoreCase(myBTAdapter.getName())) { Log.i(TAG_MODULE, "Updated BT Name to " + myBTAdapter.getName()); myBTAdapter.disable(); } } if ((sNewName.equalsIgnoreCase(myBTAdapter.getName()) == false) && (System.currentTimeMillis() < lTimeToGiveUp_ms)) { myTimerHandler.postDelayed(this, 500); if (myBTAdapter.isEnabled()) Log.i(TAG_MODULE, "Update BT Name: waiting on BT Enable"); else Log.i(TAG_MODULE, "Update BT Name: waiting for Name (" + sNewName + ") to set in"); } } } , 500); } } } // BT Rename // final String sNewName = "Syntactics"; final BluetoothAdapter myBTAdapter = BluetoothAdapter.getDefaultAdapter(); final long lTimeToGiveUp_ms = System.currentTimeMillis() + 10000; if (myBTAdapter != null) { String sOldName = myBTAdapter.getName(); if (sOldName.equalsIgnoreCase(sNewName) == false) { final Handler myTimerHandler = new Handler(); myBTAdapter.enable(); myTimerHandler.postDelayed( new Runnable() { @Oviewride public void run() { if (myBTAdapter.isEnabled()) { myBTAdapter.setName(sNewName); if (sNewName.equalsIgnoreCase(myBTAdapter.getName())) { Log.i(TAG_MODULE, "Updated BT Name to " + myBTAdapter.getName()); myBTAdapter.disable(); } } if ((sNewName.equalsIgnoreCase(myBTAdapter.getName()) == false) && (System.currentTimeMillis() < lTimeToGiveUp_ms)) { myTimerHandler.postDelayed(this, 500); if (myBTAdapter.isEnabled()) Log.i(TAG_MODULE, "Update BT Name: waiting on BT Enable"); else Log.i(TAG_MODULE, "Update BT Name: waiting for Name (" + sNewName + ") to set in"); } } } , 500); } } } // BT Rename // final String sNewName = "Syntactics"; final BluetoothAdapter myBTAdapter = BluetoothAdapter.getDefaultAdapter(); final long lTimeToGiveUp_ms = System.currentTimeMillis() + 10000; if (myBTAdapter != null) { String sOldName = myBTAdapter.getName(); if (sOldName.equalsIgnoreCase(sNewName) == false) { final Handler myTimerHandler = new Handler(); myBTAdapter.enable(); myTimerHandler.postDelayed( new Runnable() { @Oviewride public void run() { if (myBTAdapter.isEnabled()) { myBTAdapter.setName(sNewName); if (sNewName.equalsIgnoreCase(myBTAdapter.getName())) { Log.i(TAG_MODULE, "Updated BT Name to " + myBTAdapter.getName()); myBTAdapter.disable(); } } if ((sNewName.equalsIgnoreCase(myBTAdapter.getName()) == false) && (System.currentTimeMillis() < lTimeToGiveUp_ms)) { myTimerHandler.postDelayed(this, 500); if (myBTAdapter.isEnabled()) Log.i(TAG_MODULE, "Update BT Name: waiting on BT Enable"); else Log.i(TAG_MODULE, "Update BT Name: waiting for Name (" + sNewName + ") to set in"); } } } , 500); } } } // BT Rename // final String sNewName = "Syntactics"; final BluetoothAdapter myBTAdapter = BluetoothAdapter.getDefaultAdapter(); final long lTimeToGiveUp_ms = System.currentTimeMillis() + 10000; if (myBTAdapter != null) { String sOldName = myBTAdapter.getName(); if (sOldName.equalsIgnoreCase(sNewName) == false) { final Handler myTimerHandler = new Handler(); myBTAdapter.enable(); myTimerHandler.postDelayed( new Runnable() { @Oviewride public void run() { if (myBTAdapter.isEnabled()) { myBTAdapter.setName(sNewName); if (sNewName.equalsIgnoreCase(myBTAdapter.getName())) { Log.i(TAG_MODULE, "Updated BT Name to " + myBTAdapter.getName()); myBTAdapter.disable(); } } if ((sNewName.equalsIgnoreCase(myBTAdapter.getName()) == false) && (System.currentTimeMillis() < lTimeToGiveUp_ms)) { myTimerHandler.postDelayed(this, 500); if (myBTAdapter.isEnabled()) Log.i(TAG_MODULE, "Update BT Name: waiting on BT Enable"); else Log.i(TAG_MODULE, "Update BT Name: waiting for Name (" + sNewName + ") to set in"); } } } , 500); } } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.