はいあります。BroadcastReveiverでLocation Manager のaddProximityAlertを使用します。
少し前に作業したものと同様のコードの一部を配置します。これにより、何を検索するかについての一般的なアイデアが得られるはずです...
// IN SOME CLASS, YOU REGISTER BROADCAST RECEIVER FOR SOME COORDINATES
Intent thisIntent = new Intent("my.package.name.MyProximityReceiver"); // MyProximityReceiver is the name of the class where you extend BroadcastReceiver
Bundle thisBundle = new Bundle();
thisBundle.putString("placeName", "SomePlaceName");
thisIntent.putExtras(thisBundle);
PendingIntent proximityIntent = PendingIntent.getBroadcast(getBaseContext(), 0,
thisIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
LocationManager locManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locManager.addProximityAlert(40.218835,-74.000666,
10000 , -1, proximityIntent); // 10000 is the 10km radius , -1 means no expiration, read more in the link provided above
// END OF THAT SOME CLASS YOU ARE REGISTERING BROADCASTRECEIVER IN
// CLASS MyProximityReceiver
public class MyProximityReceiver extends BroadcastReceiver {
public String placeName;
@Override
public void onReceive(Context c, Intent intent) {
Log.d("TAG_IN_BROADCAST", "In broadcast receiver");
String key = LocationManager.KEY_PROXIMITY_ENTERING;
boolean entering = intent.getBooleanExtra(key, false);
Bundle thisBundle = intent.getExtras();
if (thisBundle != null)
{
placeName = thisBundle.getString("placeName");
}
if (entering)
{
Log.e("TAG_ENTERING","ENTERING");
// SOMEONE ENTERED THE AREA
}
else
{
Log.e("TAG_LEAVING", "LEAVING");
// SOMEONE EXITED THE AREA
}
...
...
}
....
}
これはおそらく機能しないでしょう (これらはコードの一部にすぎません)。
お役に立てれば...