-
- private void initGPS() {
- LocationManager locationManager = (LocationManager) this
- .getSystemService(Context.LOCATION_SERVICE);
-
- if (!locationManager
- .isProviderEnabled(android.location.LocationManager.GPS_PROVIDER)) {
- Toast.makeText(TrainDetailsActivity.this, "请打开GPS",
- Toast.LENGTH_SHORT).show();
- AlertDialog.Builder dialog = new AlertDialog.Builder(this);
- dialog.setMessage("请打开GPS");
- dialog.setPositiveButton("确定",
- new android.content.DialogInterface.OnClickListener() {
-
- @Override
- public void onClick(DialogInterface arg0, int arg1) {
-
-
- Intent intent = new Intent(
- Settings.ACTION_LOCATION_SOURCE_SETTINGS);
- startActivityForResult(intent, 0);
-
- }
- });
- dialog.setNeutralButton("取消", new android.content.DialogInterface.OnClickListener() {
-
- @Override
- public void onClick(DialogInterface arg0, int arg1) {
- arg0.dismiss();
- }
- } );
- dialog.show();
- } else {
-
- }
- }
posted @
2016-12-22 19:46
新感觉
阅读(
653)
评论()
编辑
收藏
举报