current location is always null

后端 未结 6 1879
独厮守ぢ
独厮守ぢ 2021-02-04 22:39

I am trying to retrieve my current location on the button click in an editbox using gps or network..i have tried all possible methods which i found in tutorials and older posts.

6条回答
  •  生来不讨喜
    2021-02-04 23:09

    Use this code

    if (android.os.Build.VERSION.SDK_INT > 8) {
    
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);
    
        }
    

    And also check your Settings --> Location and security --> Use wireless networks is enabled or not.

提交回复
热议问题