内容简介:判断是否开定位权限,没开并跳转权限界面
判断是否开定位权限,没开并跳转权限界面
private LocationManager lm;//【位置管理】
lm = (LocationManager) getActivity().getSystemService(getActivity().LOCATION_SERVICE);
boolean enable = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
if (enable) {//开了定位服务
if (ContextCompat.checkSelfPermission(getActivity(),Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// 没有权限,申请权限。
// Toast.makeText(getActivity(), "没有权限", Toast.LENGTH_SHORT).show();
} else {
// 有权限 do something
// Toast.makeText(getActivity(), "有权限", Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(getActivity(), "系统检测到未开启GPS定位服务", Toast.LENGTH_SHORT).show();
// 跳转到开启页面
Intent intent = new Intent();
intent.setAction(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivityForResult(intent, 200);
}
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- 认识绝对定位,相对定位
- 移动端页面头部固定定位的绝对定位实现
- webgl(three.js)实现室内定位,楼宇bim、实时定位三维可视化解决方案——第五课
- IP 地址怎么定位?
- # CSS 绝对定位释义
- 如何定位渲染耗时瓶颈
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
An Introduction to Probability Theory and Its Applications
William Feller / Wiley / 1991-1-1 / USD 120.00
Major changes in this edition include the substitution of probabilistic arguments for combinatorial artifices, and the addition of new sections on branching processes, Markov chains, and the De Moivre......一起来看看 《An Introduction to Probability Theory and Its Applications》 这本书的介绍吧!