安卓GPS启用progrmmatically [英] android GPS enable progrmmatically

查看:117
本文介绍了安卓GPS启用progrmmatically的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  启用GPS编程喜欢塔斯克

我想获得的纬度和经度计划在Android应用程序。但它依赖于GPS是否启用。我以前检查与此code中的GPS

I want to get latitude and longitude programmatic in android app. But it depended upon whether the GPS is enabled or not. I used to check the GPS with this code

   LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
    {
    if(!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER )) 
    { 
    Intent myIntent = new Intent( Settings.ACTION_LOCATION_SOURCE_SETTINGS );
    startActivity(myIntent);
    }
    }

但它基本上显示屏幕来启用它。但我不想那么用户应该启用它。如果GPS被禁用它应该自动启用。

But it basically shows the screen to enable it. But i dont want that user should enable it. It should enable automatically if the gps is disabled.

任何样品code将AP preciated。

Any sample code would be appreciated.

推荐答案

您不能开始与Android 1.5。你可以做的最多的是流行开活动,允许用户切换其开/关。

You can't, starting with Android 1.5. The most you can do is pop open the activity to allow the user to toggle it on/off.

使用在android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS举行的行动,以便起草一个意图打开此活动。

Use the action held in android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS to craft an Intent to open this activity.

这篇关于安卓GPS启用progrmmatically的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆