此代碼能夠轉到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。它應該返回到您的應用程序,但也許你的應用程序已退出或崩潰。 –