【发布时间】:2011-08-17 09:08:57
【问题描述】:
我需要在 onProviderDisabled 方法中使用以下代码。但它不会持续很长时间。 我怎样才能等到用户响应?
AlertDialog.Builder builder = new AlertDialog.Builder(Activity.this);
builder.setMessage("Your GPS is disabled! Would you like to enable it?").setCancelable(false).setPositiveButton("Enable GPS", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent gpsOptionsIntent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(gpsOptionsIntent);
}
});
builder.setNegativeButton("Do nothing", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
提前致谢!!
【问题讨论】:
标签: android geolocation locationlistener android-alertdialog