2012-04-16 66 views
0

我有一个位置侦听器,它弹出邻近警报对话框。但是,当我四处走动时,它会不断弹出相同的警报对话框。是否有办法在弹出警告对话框时禁用位置侦听器,并在用户提交或取消警报对话框时重新启用位置侦听器?LocationListener警报对话框弹出多个弹出框

+0

我认为您需要发布一些代码,以便我们可以看到您正在处理的内容。这将使建议变更更容易达到预期效果。 – breadbin 2012-04-16 15:59:11

回答

0

后您展示alertdialog

alertDialog.show(); 

呼叫

locManager.removeUpdates(locListener); 
    //here locManager is your LocationManager object and locListener is your LocationListener 

然后在再次位置监听器这样的警告对话框寄存器的一些按钮,用户点击之后..

alertDialog.setButton("OK", new DialogInterface.OnClickListener() { 
    public void onClick(DialogInterface dialog, int which) { 

    //here register for location listener again.. 

    locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, updateInterval, updateDistance, locListener); 

} }); 
+0

完美,谢谢! – Kel196 2012-04-16 16:16:04