isLocationSourceSupported

isLocationSourceSupported

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

问题描述

我开发一个应用程序中,我有GPS是否启用与否对手机位置以编程方式检查?如何找到的?


解决方案

 如果(!LocationInfo.isLocationOn()){
    尝试{
        LocationInfo.setLocationOn();
    }赶上(ControlledAccessException CAE){
        //你不必编程启用GPS的权利。
        //你可能要提示用户输入它。
    }
}

您可能还需要看看以下功能:


  • LocationInfo.isLocationSourceAvailable(INT模式) -
          确定一个特定的位置源,可提供位置信息。

  • LocationInfo.isLocationSourceSupported(INT模式) -
          确定是否当前被支承在装置上的特定位置的源。

GL

I am developing an app in which I have to check programmatically if gps is enabled or not for locations in phone? How do I find this?

解决方案
if (!LocationInfo.isLocationOn()) {
    try {
        LocationInfo.setLocationOn();
    } catch (ControlledAccessException cae) {
        // You don't have the rights to enable GPS programatically.
        // You might want to prompt the user for it.
    }
}

You might also want to have a look at the following functions:

  • LocationInfo.isLocationSourceAvailable(int mode) - Determines if a specific location source is available to provide location information.
  • LocationInfo.isLocationSourceSupported(int mode) - Determines if a specific location source is currently supported on the device.

gl

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

07-26 08:31