android 在程序中开启GPS功能
来源:互联网 发布:win10 未识别的网络 编辑:程序博客网 时间:2024/06/05 05:12
LocationManager locationManager=(LocationManager) getSystemService(Context.LOCATION_SERVICE); boolean isEnabled= locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);if(!isEnabled){//这段代码可以实现GPS开关状态的切换 Intent GPSIntent = new Intent(); GPSIntent.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider"); GPSIntent.addCategory("android.intent.category.ALTERNATIVE"); GPSIntent.setData(Uri.parse("custom:3")); try { PendingIntent.getBroadcast(MainActivity.this, 0, GPSIntent, 0).send(); } catch (CanceledException e) { e.printStackTrace(); } //Settings.Secure.setLocationProviderEnabled(getContentResolver(), LocationManager.GPS_PROVIDER, true);
注释掉的代码,表面上看可以简单的实现开启GPS功能,但是运行后发现后没有权限,即使加了权限依旧提示permission denied
- android 在程序中开启GPS功能
- android 在程序中开启GPS功能
- 在桌面程序中添加GPS功能
- 如何在android4.0中开启GPS
- android 自动开启gps
- Android自动开启GPS
- android设置gps开启
- android 强制开启 GPS
- Android GPS 自动开启
- Android -开启GPS权限
- 开启Android程序时检测网络与GPS是否打开
- 开启Android程序时检测网络与GPS是否打开
- 开启Android程序时检测网络与GPS是否打开
- 开启Android程序时检测网络与GPS是否打开
- 开启Android程序时检测网络与GPS是否打开
- 在Android程序中调用摄像头功能
- Android中如何监听GPS开启和关闭
- Android中如何监听GPS开启和关闭
- java中的sdk与jdk的区别
- Chapter 1: J2EE Architectures 第一章 J2EE框架 【概述】
- java synchronized详解
- Android开发环境搭建全程演示(jdk+eclip+android sdk)
- 使用addView方法时,如何保持已有动态控件位置不被改变
- android 在程序中开启GPS功能
- Linux sqlite3基本命令
- Android中View绘制流程以及invalidate()等相关方法分析
- datatable 转化为 List
- ANDROID解决屏幕旋转而导致重启ACTIVITY
- 关于oracle调整列顺序的记录
- ffmpeg将音视频文件转换为wav文件
- VC做的简易示波器
- 设置UIBarButtonItem tintColor