1

I write the solution in this link

     context.getResources().getConfiguration().getLocales().get(0).getDisplayCountry()

but it doesn't get the user's country. it always shows my own country. when as a user, I use VPN from other countries and println the result, the result doesn't change. am I writing the correct code?

besides, I'm using KOTLIN. is the code the same in KOTLIN and JAVA in this case?!

I just want to find out the user's country, so I can show different content to different people. How should I do that?

Reza Zeraati
  • 303
  • 1
  • 8

1 Answers1

1

You're always getting the same country from the list because of .get(0)

Saad Waseem
  • 113
  • 1
  • 9
  • 1
    thanks. I didn't know the meaning of the code. But when I remove it or remove the zero inside the parentheses, it gives an error. How should I change that code to become what I want? – Reza Zeraati Sep 20 '22 at 07:52
  • 1
    @rezazeraati There are a couple of solutions in [this](https://stackoverflow.com/questions/3659809/where-am-i-get-country). – Saad Waseem Sep 21 '22 at 07:12