BroadcastReceiver updateBooleanBroadCastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
if (intent.getBooleanExtra("action", true)) {
checkGPS();
} else {
checkGPS();
}
}
};
private void checkGPS(){
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L,1.0f, this);
boolean isGPS = locationManager.isProviderEnabled (LocationManager.GPS_PROVIDER);
if(isGPS){
}else{
Utils.displayPromptForEnablingGPS(true,MainActivity.this);
}
}
接收器接收這是我的提醒:如何顯示和解僱alertDilog在全球範圍內時,曾經在安卓
public static void
displayPromptForEnablingGPS(boolean a,
final Activity activity) {
final AlertDialog.Builder builder =
new AlertDialog.Builder(activity);
final String action = Settings.ACTION_LOCATION_SOURCE_SETTINGS;
final String message = "Enable either GPS or any other location"
+ " service to find current location. Click OK to go to"
+ " location services settings to let you do so.";
builder.setMessage(message).setCancelable(false)
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface d, int id) {
activity.startActivityForResult(new Intent(action),1);
d.dismiss();
}
})
.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface d, int id) {
activity.finish();
}
});
builder.create().show();
}
我想隱藏Alertdilog時位置在,當我想隱藏或關閉時的位置關閉通知管理員位置我可以在我們關閉時收到接收方法的事件,並且在位置管理者位置時,當我離開位置管理員的位置時,我可以顯示警報但我無法禁用警報當我在位置PLZ幫助我時我將如何實現這一點,請建議。
但這樣做在你的活動廣播reciever其不隱藏當我在位置它顯示警告時,位置關閉但是當我在位置它不隱藏@raj –
你想要顯示時打開或關閉 – raj
是當它應該自動隱藏我不想點擊任何東西 –