此代码能够转到GPS设置并打开它,但按下它并不意图回到应用程序。相反,它将我带到我的发射器的家中。意图打开GPS并返回到应用程序
public void createDialog(){
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle(R.string.gps_message);
alert.setPositiveButton(R.string.gps_settings, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
startActivityForResult(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS), 0);
return;
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
return;
}
});
alert.create();
alert.show();
}
您可以发布创建对话框的代码请。 – vguzzi
检查你的logcat。它应该返回到您的应用程序,但也许你的应用程序已退出或崩溃。 –