像OLA出租车应用程序一样自动打开GPS

编程入门 行业动态 更新时间:2024-10-23 19:33:27
本文介绍了像OLA出租车应用程序一样自动打开GPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图自动开启GPS。但我找不到解决方案。现在我正在使用像导航到设置页面打开GPS。在OLA出租车应用程序gps自动开启。我想像OLA出租车一样自动打开GPS位置。

public void MessageNoGps(final Activity mActivity){ final AlertDialog .Builder builder = new AlertDialog.Builder(mActivity); builder.setMessage(mActivity.getString(R.string.gps_enable)) .setCancelable(false) .setPositiveButton(mActivity.getString(R.string.yes),新的DialogInterface.OnClickListener(){ public void onClick(final DialogInterface对话框, final int id){ mActivity .startActivity(new Intent( android.provider (), .setNegativeButton b public void onClick(最终的DialogInterface对话框, final int id){ dialog.cancel(); mActivity.finish(); } }); 最终AlertDialog alert = builder.create(); alert.show(); }

请让我知道如何自动打开GPS。

解决方案

Ola Cabs使用新发布的设置API来实现此功能。根据新的API,用户不需要导航到设置页面以启用位置服务,从而实现相同的无缝集成。请阅读以下内容以了解更多详情:

在此处输入链接描述

I am trying to turn on the gps automatically. But I can not find the solution for this. Now I am using like navigate to the settings page to turn on the GPS. In OLA cabs app gps is automatically on. I want to turn on the GPS location automatically like OLA cabs. I am using following code for switch on the GPS.

public void MessageNoGps(final Activity mActivity) { final AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); builder.setMessage(mActivity.getString(R.string.gps_enable)) .setCancelable(false) .setPositiveButton(mActivity.getString(R.string.yes), new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { mActivity .startActivity(new Intent( android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS)); } }) .setNegativeButton(mActivity.getString(R.string.no), new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { dialog.cancel(); mActivity.finish(); } }); final AlertDialog alert = builder.create(); alert.show(); }

Please let me know how to turn on the GPS automatically.

解决方案

Ola Cabs is using the newly released Settings API to achieve this functionality. As per the new API the user is not required to navigate to the settings page to enable location services giving a seamless integration for the same. Please read below for more details:

enter link description here

更多推荐

像OLA出租车应用程序一样自动打开GPS

本文发布于:2023-11-30 21:05:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1651466.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:出租车   应用程序   OLA   GPS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!