Created
October 7, 2013 14:32
-
-
Save sakurabird/6868981 to your computer and use it in GitHub Desktop.
Androidのシステム位置情報をoffにしているユーザーに設定を促すダイアログ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package xxxxx.fragment; | |
import android.app.AlertDialog; | |
import android.app.Dialog; | |
import android.content.DialogInterface; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.support.v4.app.DialogFragment; | |
import xxxxx.R; | |
public class RequestGPSDialogFragment extends DialogFragment { | |
static RequestGPSDialogFragment newInstance() { | |
RequestGPSDialogFragment f = new RequestGPSDialogFragment(); | |
return f; | |
} | |
@Override | |
public Dialog onCreateDialog(Bundle savedInstanceState) { | |
return new AlertDialog.Builder(getActivity()) | |
.setMessage(getActivity().getResources().getString(R.string.dialog_gps_enable)) | |
.setPositiveButton( | |
getActivity().getResources().getString(R.string.dialog_gps_enable_button), | |
new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int whichButton) { | |
Intent callGPSSettingIntent = new Intent( | |
android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); | |
startActivity(callGPSSettingIntent); | |
dismiss(); | |
} | |
} | |
) | |
.setNegativeButton(android.R.string.cancel, | |
new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int whichButton) { | |
dismiss(); | |
} | |
} | |
) | |
.create(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment