Android 判断GPS是否打开
来源:互联网 发布:iphone自动点击软件 编辑:程序博客网 时间:2024/05/29 15:36
<span style="font-size:18px;"><strong></strong></span>
<span style="font-size:18px;"><strong>代码如下:</strong></span>
<span style="font-size:18px;"><strong>private void openGPSSetting(){LocationManager alm = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);if(alm.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER)){Toast.makeText(MainActivity.this,"GPS已打开",Toast.LENGTH_SHORT).show();}else {AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.this);dialog.setTitle("提示");dialog.setMessage("请打开GPS开关!");dialog.setPositiveButton("确定",new OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {// TODO Auto-generated method stubIntent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);startActivityForResult(intent, 2111);}});dialog.setNegativeButton("取消", new OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {// TODO Auto-generated method stubdialog.dismiss();}});dialog.show();}}</strong></span>
<span style="font-size:18px;"><strong></strong></span>
<span style="font-size:18px;"><strong>最后还要在清单文件中添加对应的权限:</strong></span>
<span style="font-size:18px;"><strong></strong></span><pre name="code" class="java"> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
0 0
- android判断gps是否打开
- Android 判断GPS是否打开
- Android判断gps是否打开
- Android判断是否连接网络或者是否打开了GPS
- 【Android】- Android判断GPS定位是否打开弹出对话框
- Android判断GPS是否开启和强制帮用户打开GPS
- Android判断GPS是否开启和强制帮用户打开GPS
- Android判断GPS是否开启和强制帮用户打开GPS
- Android判断GPS是否开启和强制帮用户打开GPS
- Android判断GPS是否开启和强制帮用户打开GPS
- Android判断GPS是否开启和强制帮用户打开GPS
- Android 判断GPS是否开启和强制帮用户打开GPS
- Android判断GPS是否开启和强制帮用户打开GPS
- Android判断GPS是否开启和强制帮用户打开GPS
- Android判断GPS是否开启和强制帮用户打开GPS
- 判断GPS定位服务是否打开
- 工作积累-判断GPS是否打开
- Android 判断GPS是否开启
- idea 14 Error: Failed to create a child event loop
- CodeForces 296C Greg and Array (线段树)
- redislinux安装、windows扩展安装及使用
- Error:activity xxx has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41971600
- iOS开发学习中用到的3DES密码算法
- Android 判断GPS是否打开
- Symfony2 安装
- 行文字的垂直对齐方式valign
- 网络布局基础
- MFC中动态生成CComBox,响应CComBox选中项的消息ON_CBN_SELCHANGE,并获取项的值
- 南阳oj题目35 表达式求值【栈的应用】
- 逻辑回归及美团逻辑回归总结
- GTK入门学习:Libglade 和 GtkBuilder 的区别使用
- 如何在工程中使用自定义字体