简体   繁体   English

在Android上更改设备名称

[英]Change device name on android

I tried to change the device name on my tablet but for some reason it does not save. 我试图在平板电脑上更改设备名称,但由于某种原因无法保存。 After changing I check and it's still the same, don't really know what's happening. 更改后,我检查并且它仍然相同,真的不知道发生了什么。 I also have included the permissions too, here is my code: 我也包括了权限,这是我的代码:

BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
myDevice.setName("new device name");

And here are my permissions: 这是我的权限:

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

You'll need to enable Developer Options on the tablets, but after doing so, use the following setting. 您需要在平板电脑上启用“开发人员选项”,但之后请使用以下设置。

Settings > Developer Options > Device hostname 设置>开发人员选项>设备主机名

This will allow you to change, obviously, the hostname that the tablet uses. 显然,这将使您能够更改平板电脑使用的主机名。 You'll want to reboot the tablet to ensure it refreshes properly on the network side. 您需要重新启动平板电脑,以确保其在网络端正确刷新。 However, not every device may have this option. 但是,并非每个设备都有此选项。 If you don't see it after enabling Developer Options, use the following method, though it will require root access. 如果启用“开发人员选项”后看不到它,请使用以下方法,尽管它需要root访问权限。 You should be able to unroot without having the hostname reset, but don't quote me on that. 您应该能够在不重置主机名的情况下取消root用户身份,但是不要在此引用我。 I'd give it a try with the first tablet to see whether or not it will work. 我会尝试使用第一个平板电脑,看看它是否可以正常工作。

Install a terminal emulator on the tablet. 在平板电脑上安装终端仿真器。 Enter the following: 输入以下内容:

Code: 码:

> su
> getprop net.hostname
> setprop net.hostname <new_hostname>

The 'getprop' command will return the current hostname, so you can double-check it before setting the new one. “ getprop”命令将返回当前主机名,因此您可以在设置新主机名之前对其进行仔细检查。 Again, reboot to refresh network assignments. 同样,重新启动以刷新网络分配。

http://forums.androidcentral.com/android-4-1-4-2-4-3-jelly-bean/289961-lots-tablets-how-do-i-rename-them.html#post2872407 http://forums.androidcentral.com/android-4-1-4-2-4-3-jelly-bean/289961-lots-tablets-how-do-i-rename-them.html#post2872407

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM