在 Appcelerator Titanium 中获取网络运营商名称 [英] Get network operator name in Appcelerator Titanium
问题描述
我希望获取用户 Android 设备的运营商名称.
I am looking to get the name of the operator for the user's Android device.
例如Verizon"或Vodafone",我想我已经从 http://developer.android.com/reference/android/telephony/TelephonyManager.html#getNetworkOperatorName()
E.g. "Verizon" or "Vodafone", I think I have found the Android equivalent documented here called getSimOperatorName() from http://developer.android.com/reference/android/telephony/TelephonyManager.html#getNetworkOperatorName()
我正在浏览 Appcelerator Titanium 的文档,但似乎在文档中找不到这样做的方法 (http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Network).
I am scanning over the documentation for Appcelerator Titanium, but can't seem to find a way of doing this in the docs (http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Network).
这在 Appcelerator Titanium 中可行吗?
Is this possible in Appcelerator Titanium?
推荐答案
我无法让 tinetworkinfo 模块工作.但是,名为 TelephonyManager 的模块运行良好.
I could not get tinetworkinfo Module working. However, a module named TelephonyManager worked fine.
我在项目的终端中运行了这个:
I ran this in the terminal for the project:
gittio 安装 com.goyya.telephonymanager
gittio install com.goyya.telephonymanager
然后这段代码获取网络运营商名称:
Then this code to get the network operator name:
var telephonymanager = require("com.goyya.telephonymanager");
Ti.API.log('networkOperatorName: ' + telephonymanager.networkOperatorName);
这篇关于在 Appcelerator Titanium 中获取网络运营商名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!