我在这里看到了 Commonwares LocationPoller 演示 github.com/commonsguy/cwac-locpoll/
在这里,LocationReceiver
我正在检查该位置是否在指定区域内。如果不在那个区域,我会向电话号码发送短信(SMS)。
但它会在每个特定间隔接收新位置时连续发送文本消息(SMS)。所以我定义了一个类变量flag
=0(最初)
public class LocationReceiver extends BroadcastReceiver {
int flag=0;
public void onReceive(Context context, Intent intent) {
............
if( flag==0) //center of campus
{
checkArea(loc,"500","22.599669","72.820473","5556","Your ward is out of College campus");
Toast.makeText(context, "You Have Moved out",Toast.LENGTH_SHORT);
flag=1;
}
}
}
但它不起作用,它仍然连续发送短信。我应该怎么办 ?