android - 无法获取用户使用我的 Android 应用程序的国家/地区

标签 android android-activity android-studio telephonymanager

我无法获取用户使用我的 Android 应用程序的确切国家/地区。 我尝试了很多方法但没有得到确切的答案。

首先我像这样使用 TelephonyManager 但没有得到确切的答案

TelephonyManager tMgr = (TelephonyManager) CheckCountry.this
                    .getSystemService(Context.TELEPHONY_SERVICE);
            phNo = tMgr.getLine1Number();

然后我使用了这个,但它通过从我的移动设置获取返回值

String locale = getApplicationContext().getResources()
                    .getConfiguration().locale.getCountry();

有任何一个精确的解决方案,我可以通过它获得国家/地区名称,然后让我知道

最佳答案

好吧,我找到了更好的解决方案。通过使用此 api,我可以获得有关用户当前位置和国家/地区的所有详细信息。这是API

API to Get Country

关于android - 无法获取用户使用我的 Android 应用程序的国家/地区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30521636/

相关文章:

android - 如何检测物体的外框

android - 将用户重定向到 Android 中的 App Store

android - 何时取消注册 LocalBroadcastManager 接收器?

android - 为什么当有 android:name ="android.intent.action.VIEW"时 Action android :name ="android.intent.action.MAIN" added into AndroidManifest. xml

Android Studio 卡在 Refreshing Gradle 项目上

android - 将 EditText View 动态插入 Listview 时,虚拟键盘不会打开

Android显示搜索结果的方法

Android:getArguments() 总是得到空值

android - FLAG_ACTIVITY_CLEAR_TOP 和 onActivityResult

java - 如何在 Intellij IDE(特别是 Android Studio)中创建并运行具有依赖项的可执行 jar?