我有一个几乎总是需要知道用户位置的应用程序。请求用户打开Wi-Fi
当我需要访问一个位置,我这样做:
final AlertDialog.Builder builder = new AlertDialog.Builder(
MapScreen.this);
builder.setTitle("MyAppName");
builder.setMessage("The location service is off. Do you want to turn it on?");
builder.setPositiveButton("Enable location",
new DialogInterface.OnClickListener() {
@Override
public void onClick(
final DialogInterface dialogInterface,
final int i) {
startActivity(new Intent(
android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
}
});
builder.setNegativeButton("Continue without location", null);
builder.create().show();
但是,GPS给我一些信息并不总是足够精确。 Wi-Fi总是给我足够的精度,所以我想要求用户打开Wi-Fi,就像我要求他们打开位置一样。我不想只打开它,我希望用户得到通知,并手动启用它。
是否有任何意图将WiFi菜单带给用户?
你也可以试试这个[Enable wifi](http://stackoverflow.com/a/5674685/1083388) – 2013-05-14 09:24:19