Android “onRequestPermissionsResult” not being called

前端 未结 3 670
旧巷少年郎
旧巷少年郎 2021-01-21 16:42

I\'m trying to implement Marshmallow\'s permission support, but my code inside \"onRequestPermissionsResult\" is never called. The \"onCreate\" and \"onMapReady\" parts of the c

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-21 17:19

    This line will never evaluate to true:

    permissions[0] == android.Manifest.permission.ACCESS_FINE_LOCATION
    

    Because you are comparing these two strings by reference.

    You should use TextUtils.equals()

    TextUtils.equals(permissions[0], android.Manifest.permission.ACCESS_FINE_LOCATION)
    

提交回复
热议问题