用于定位的android广播接收器

用于定位的android广播接收器,android,broadcastreceiver,Android,Broadcastreceiver,在应用程序中,我的互联网状态有一个广播接收器: public class InternetStateChange extends BroadcastReceiver { private Context context; public InternetStateChange() { super(); } public void onReceive(Context context, Intent intent) { this.context = context

在应用程序中,我的互联网状态有一个广播接收器:

public class InternetStateChange extends BroadcastReceiver {

private Context context;

public InternetStateChange() {
    super();        
} 

public void onReceive(Context context, Intent intent) {
    this.context = context;
    InternetState.updateInternetListener(isInternetOn());
}

public boolean isInternetOn() {
    final ConnectivityManager connMgr = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
    final NetworkInfo internet = connMgr.getActiveNetworkInfo();  

     if (internet != null && internet.isConnected()) 
         return true; 
     return false;       
}

}
是否可以对位置状态执行类似操作?
我不是为了改变位置才这么做的。我只想能够确定手机是否能够获取当前位置(如therinernet.inConnected()方法)

看看,当提供商启用/禁用时,会有广播发送。还有一种方法可以检查所有可用的位置提供程序以及它们是否已启用。

您的意思是在设备打开和关闭时检测设备是否具有gps硬件和广播?同样,在打开或关闭无线网络时,检测是否有无线网络硬件和广播?是,但不限于gps。gps或位置服务提供程序您是指getPrividers(true)方法吗?getProviders(布尔启用)提供所有提供程序的列表,使用isProviderEnabled(字符串提供程序),您可以检查用户是否启用或禁用了dem。如果用户更改了其中一个提供程序,则会发送一个广播,并启用键\u PROVIDER\u以获取新配置。