本文介绍了Android:获取“设备名称"在安卓电视上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道这个问题经常被问到,但无论我怎么尝试都找不到答案.
I know this question is something that is often asked but no matter what I tried I couldn't find the answer.
我使用 AVD 安卓电视 (API 24) 并想访问它:
I use an AVD android TV (API 24) and want to access this :
如何在我的应用中访问此名称?即使使用 adb 我也从未发现过...
How can I access this name in my app ? Even with adb I never found it...
推荐答案
这适用于我的 AVD(API 级别 24).
this is worked for my AVD (API level 24).
String deviceName = Settings.Global.getString(getContentResolver(), "device_name");
您还可以使用常量 Settings.Global.DEVICE_NAME
.
Instead of the string "device_name", you can also use the constant Settings.Global.DEVICE_NAME
.
此属性已移至 API 17 中的 Settings.Global
.
This property was moved into Settings.Global
in API 17.
在 API 17 之前,以下代码应该可以工作:
Before API 17, the following code should work:
String deviceName = Settings.System.getString(getContentResolver(), "device_name");
这篇关于Android:获取“设备名称"在安卓电视上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!