4

在我的 android 应用程序中,我有地图视图和当前位置,现在显示最近的剧院我想在用户进入剧院(如地理围栏)时通知用户我在 NET 上搜索并尝试找到任何支持地理围栏的 Android api 请帮助如何做到这一点?

注意:我试过http://geofence.locationlabs.com/ 但不工作意味着 API 密钥不是 comig。任何示例代码都非常有用 在此先感谢

4

1 回答 1

6

嘿,我找到了解决方案试试这个,

我们必须实现 PendingIntent & Location Manager。位置管理器获取用户的当前位置,当用户进入某个区域时,它将触发一个未决意图,一些代码片段如下:

//---use the LocationManager class to obtain locations data---
lm = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
//---PendingIntent to launch activity if the user is within some locations---
PendingIntent pendIntent = PendingIntent.getActivity(
this, 0, new
Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://www.amazon.com")), 0);
lm.addProximityAlert(37.422006, -122.084095, 5, -1, pendIntent);

addProximityAlert 方法,我们可以在其中设置区域(用户跟踪的半径) 这里是 addProximityAlert 方法的更多细节。

于 2012-05-09T06:47:08.917 回答