Android : Get “device name” on android tv

心已入冬 提交于 2019-11-26 22:26:47

问题


I know this question is something that is often asked but no matter what I tried I couldn't find the answer.

I use an AVD android TV (API 24) and want to access this :

How can I access this name in my app ? Even with adb I never found it...


回答1:


this is worked for my AVD (API level 24).

String deviceName = Settings.Global.getString(getContentResolver(), "device_name");

Instead of the string "device_name", you can also use the constant Settings.Global.DEVICE_NAME.


This property was moved into Settings.Global in API 17.

Before API 17, the following code should work:

String deviceName = Settings.System.getString(getContentResolver(), "device_name");


来源:https://stackoverflow.com/questions/44452942/android-get-device-name-on-android-tv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!