Android check permission for LocationManager

后端 未结 6 810
我寻月下人不归
我寻月下人不归 2020-11-28 01:35

I\'m trying to get the GPS coordinates to display when I click a button in my activity layout. The following is the method that gets called when I click the button:

6条回答
  •  眼角桃花
    2020-11-28 01:57

    The last part of the error message you quoted states: ...with ("checkPermission") or explicitly handle a potential "SecurityException"

    A much quicker/simpler way of checking if you have permissions is to surround your code with try { ... } catch (SecurityException e) { [insert error handling code here] }. If you have permissions, the 'try' part will execute, if you don't, the 'catch' part will.

提交回复
热议问题