【问题标题】:BroadCast Receiver gps turn on/off message information [duplicate]广播接收器 gps 打开/关闭消息信息 [重复]
【发布时间】:2016-03-27 11:52:15
【问题描述】:

我创建了一个广播接收器,用于获取在 android 中打开或关闭 gps 的信息。 使用的代码:

public class GpsReceiver extends BroadcastReceiver{

    @Override
    public void onReceive(Context context, Intent intent) {
          if (intent.getAction().matches("android.location.PROVIDERS_CHANGED")) {
               Log.i("DIGICERTO","ALTEROU GPS");
            }
    }

}

我没有响应日志,为什么?

【问题讨论】:

  • 请说明您在哪里以及如何注册此BroadcastReceiver,并说明您是如何测试它的。
  • <receiver android:name="com.digicerto.service.GpsReceiver"><intent-filter><action android:name="android.location.PROVIDERS_CHANGED"></action><category android :name="android.intent.category.DEFAULT"></category></intent-filter></receiver> 我的测试,如果打开或关闭 gps,没有日志视图。

标签: android gps android-location fusedlocationproviderapi


【解决方案1】:

您必须使用 Intent-filter 在清单上注册此接收器 android.location.PROVIDERS_CHANGED

【讨论】:

  • 是的,我是
猜你喜欢
  • 2014-01-07
  • 1970-01-01
  • 2010-10-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-12-08
  • 1970-01-01
  • 2015-10-25
相关资源
最近更新 更多