如何在Android进入电影院时通知用户?

时间:2012-05-08 11:47:08

标签: android google-maps geofencing

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

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

1 个答案:

答案 0 :(得分:6)

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

我们必须实施PendingIntent&位置经理。位置管理器获取用户的当前位置,当用户在某个地区输入时,它将触发一个待处理的意图,如下所示:

//---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方法,我们可以在其中设置区域(用户跟踪的半径) here是addProximityAlert方法的更多细节。