Example usage for android.provider Settings ACTION_LOCATION_SOURCE_SETTINGS

List of usage examples for android.provider Settings ACTION_LOCATION_SOURCE_SETTINGS

Introduction

In this page you can find the example usage for android.provider Settings ACTION_LOCATION_SOURCE_SETTINGS.

Prototype

String ACTION_LOCATION_SOURCE_SETTINGS

To view the source code for android.provider Settings ACTION_LOCATION_SOURCE_SETTINGS.

Click Source Link

Document

Activity Action: Show settings to allow configuration of current location sources.

Usage

From source file:mobisocial.musubi.ui.FeedDetailsActivity.java

public void onClickBroadcast(View v) {
    long id = Long.parseLong(getIntent().getData().getLastPathSegment());
    FeedManager fm = new FeedManager(App.getDatabaseSource(this));
    final MFeed f = fm.lookupFeed(id);

    String provider = Settings.Secure.getString(this.getContentResolver(),
            Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
    if (provider == null || !provider.contains("gps") || !provider.contains("network")) {
        new AlertDialog.Builder(this).setTitle("Location Settings").setMessage(
                "You should enable both network-based and GPS-based location services to ensure your friends can find your groups.")
                .setNegativeButton("Share Anyway", new DialogInterface.OnClickListener() {
                    @Override//from w  w  w.j  a  v  a2  s .  c  om
                    public void onClick(DialogInterface dialog, int which) {
                        new GpsBroadcastTask(mContext, f, mBroadcastPassword.getText().toString()).execute();
                    }
                }).setPositiveButton("Fix Settings First", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        try {
                            Intent myIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                            startActivity(myIntent);
                        } catch (Throwable t) {
                            Log.e(TAG, "failed to launch location settings", t);
                        }
                    }
                }).show();
    } else {
        new GpsBroadcastTask(mContext, f, mBroadcastPassword.getText().toString()).execute();
    }
}

From source file:org.egov.android.view.activity.ComplaintDetailActivity.java

/**
 * Function called if the user didn't enable GPS/Location in their device.
 * Give options to enable GPS/Location and cancel the pop up.
 *///  w  w w .  ja  v  a2  s . co  m
public void _showSettingsAlert() {
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
    alertDialog.setTitle("Settings");
    alertDialog.setMessage("Enable Location Provider! Go to settings menu?");
    alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            startActivity(intent);
        }
    });
    alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    alertDialog.show();
}

From source file:com.yammy.meter.MainActivity.java

private void requestGPS() {
    Toast.makeText(this, "Pastikan GPS sudah aktif", Toast.LENGTH_LONG).show();
    Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    startActivity(intent);/*from   w ww  . j  a v  a 2s. com*/
}

From source file:com.google.android.apps.mytracks.fragments.MapFragment.java

@Override
public void onClick(View v) {
    if (v == messageTextView) {
        Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
        startActivity(intent);//w  w w  .j ava2s . c o m
    }
}

From source file:com.example.angelina.travelapp.places.PlacesActivity.java

private void checkSettings() {
    // Is GPS enabled?
    final boolean gpsEnabled = locationTrackingEnabled();
    // Is there internet connectivity?
    final boolean internetConnected = internetConnectivity();

    if (gpsEnabled && internetConnected) {
        completeSetUp();//from  www  .ja  v a2 s  .  c om
    } else if (!gpsEnabled) {
        final Intent gpsIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
        showDialog(gpsIntent, REQUEST_LOCATION_SETTINGS, getString(R.string.location_tracking_off));
    } else if (!internetConnected) {
        final Intent internetIntent = new Intent(Settings.ACTION_WIFI_SETTINGS);
        showDialog(internetIntent, REQUEST_WIFI_SETTINGS, getString(R.string.wireless_off));
    }
}

From source file:com.example.devesh.Coride.DriverRegistration.java

public void showSettingsAlert(String provider) {
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(DriverRegistration.this);

    alertDialog.setTitle(provider + " SETTINGS");

    alertDialog.setMessage(provider + " is not enabled! Want to go to settings menu?");

    alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            DriverRegistration.this.startActivity(intent);
            dialog.cancel();//from   ww  w.j  a  va  2 s  .com
        }
    });

    alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            Toast.makeText(getApplicationContext(), "Enable location to use APP", Toast.LENGTH_SHORT).show();
            dialog.cancel();

        }
    });

    alertDialog.show();
}

From source file:es.rgmf.libresportgps.MainActivity.java

/**
 * Check if GPS is enabled. If GPS is not enabled then It shows an Dialog
 * through the user can enabled it./*from  w  w  w  .  j  av a  2s . com*/
 */
private void checkGpsProvider() {
    LocationManager lm = (LocationManager) getSystemService(LOCATION_SERVICE);
    if (!lm.isProviderEnabled(LocationManager.GPS_PROVIDER) && !Session.isAlertDialogGPSShowed()) {
        Session.setAlertDialogGPSShowed(true);
        new AlertDialog.Builder(this).setTitle(R.string.gps_disabled)
                .setIcon(android.R.drawable.ic_dialog_alert)
                .setMessage(getResources().getString(R.string.gps_disabled_hint)).setCancelable(true)
                .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
                    }
                }).setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                }).create().show();
    }
}

From source file:com.prey.activities.CheckPasswordActivity.java

@Override
protected void onResume() {
    super.onResume();
    bindPasswordControls();//ww  w . jav a 2s. c om
    TextView device_ready_h2_text = (TextView) findViewById(R.id.device_ready_h2_text);
    final TextView textForgotPassword = (TextView) findViewById(R.id.link_forgot_password);

    Button password_btn_login = (Button) findViewById(R.id.password_btn_login);
    EditText password_pass_txt = (EditText) findViewById(R.id.password_pass_txt);

    TextView textView1 = (TextView) findViewById(R.id.textView1);
    TextView textView2 = (TextView) findViewById(R.id.textView2);

    Typeface titilliumWebRegular = Typeface.createFromAsset(getAssets(),
            "fonts/Titillium_Web/TitilliumWeb-Regular.ttf");
    Typeface titilliumWebBold = Typeface.createFromAsset(getAssets(),
            "fonts/Titillium_Web/TitilliumWeb-Bold.ttf");
    Typeface magdacleanmonoRegular = Typeface.createFromAsset(getAssets(),
            "fonts/MagdaClean/magdacleanmono-regular.ttf");

    textView1.setTypeface(magdacleanmonoRegular);
    textView2.setTypeface(magdacleanmonoRegular);

    device_ready_h2_text.setTypeface(titilliumWebRegular);
    textForgotPassword.setTypeface(titilliumWebBold);
    password_btn_login.setTypeface(titilliumWebBold);
    password_pass_txt.setTypeface(magdacleanmonoRegular);

    try {

        textForgotPassword.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                try {
                    String url = PreyConfig.getPreyConfig(getApplicationContext()).getPreyPanelUrl();
                    Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse(url));
                    startActivity(browserIntent);
                } catch (Exception e) {
                }
            }
        });
    } catch (Exception e) {
    }

    TextView textView5_1 = (TextView) findViewById(R.id.textView5_1);
    TextView textView5_2 = (TextView) findViewById(R.id.textView5_2);

    textView5_1.setTypeface(magdacleanmonoRegular);
    textView5_2.setTypeface(titilliumWebBold);

    TextView textViewUninstall = (TextView) findViewById(R.id.textViewUninstall);
    LinearLayout linearLayoutTour = (LinearLayout) findViewById(R.id.linearLayoutTour);
    textViewUninstall.setTypeface(titilliumWebBold);

    if (PreyConfig.getPreyConfig(getApplication()).getProtectTour()) {
        linearLayoutTour.setVisibility(View.GONE);
        textViewUninstall.setVisibility(View.VISIBLE);

        textViewUninstall.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String url = PreyConfig.getPreyConfig(getApplication()).getPreyUninstallUrl();

                Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse(url));
                startActivity(browserIntent);

                finish();
            }
        });
    } else {

        linearLayoutTour.setVisibility(View.VISIBLE);
        textViewUninstall.setVisibility(View.GONE);
        try {

            linearLayoutTour.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(getApplication(), TourActivity1.class);
                    Bundle b = new Bundle();
                    b.putInt("id", 1);
                    intent.putExtras(b);
                    startActivity(intent);
                    finish();
                }
            });
        } catch (Exception e) {

        }
    }

    boolean showLocation = false;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        boolean canAccessFineLocation = PreyPermission.canAccessFineLocation(this);
        boolean canAccessCoarseLocation = PreyPermission.canAccessCoarseLocation(this);
        boolean canAccessCamera = PreyPermission.canAccessCamera(this);
        boolean canAccessReadPhoneState = PreyPermission.canAccessReadPhoneState(this);
        boolean canAccessReadExternalStorage = PreyPermission.canAccessReadExternalStorage(this);

        if (!canAccessFineLocation || !canAccessCoarseLocation || !canAccessCamera || !canAccessReadPhoneState
                || !canAccessReadExternalStorage) {

            AlertDialog.Builder builder = new AlertDialog.Builder(this);

            final FrameLayout frameView = new FrameLayout(this);
            builder.setView(frameView);

            final AlertDialog alertDialog = builder.create();
            LayoutInflater inflater = alertDialog.getLayoutInflater();
            View dialoglayout = inflater.inflate(R.layout.warning, frameView);

            TextView warning_title = (TextView) dialoglayout.findViewById(R.id.warning_title);
            TextView warning_body = (TextView) dialoglayout.findViewById(R.id.warning_body);

            warning_title.setTypeface(magdacleanmonoRegular);
            warning_body.setTypeface(titilliumWebBold);

            Button button_ok = (Button) dialoglayout.findViewById(R.id.button_ok);
            Button button_close = (Button) dialoglayout.findViewById(R.id.button_close);
            button_ok.setTypeface(titilliumWebBold);
            button_close.setTypeface(titilliumWebBold);

            final Activity thisActivity = this;
            button_ok.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    PreyLogger.d("askForPermission");
                    askForPermission();
                    alertDialog.dismiss();

                }
            });

            button_close.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    PreyLogger.d("close ask");

                    alertDialog.dismiss();
                }
            });

            alertDialog.show();
            showLocation = false;

        } else {
            showLocation = true;
        }

    } else {
        showLocation = true;
    }
    if (showLocation) {
        LocationManager mlocManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
        boolean isGpsEnabled = mlocManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
        boolean isNetworkEnabled = mlocManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
        if (isGpsEnabled || isNetworkEnabled) {
            PreyLogger.d("isGpsEnabled || isNetworkEnabled");

        } else {
            PreyLogger.d("no gps ni red");
            AlertDialog.Builder builder = new AlertDialog.Builder(this);

            final AlertDialog alertDialog = builder.create();
            TextView textview = new TextView(this);
            textview.setText(getString(R.string.location_settings));
            textview.setMaxLines(10);
            textview.setTextSize(18F);
            textview.setPadding(20, 0, 20, 20);
            textview.setTextColor(Color.BLACK);
            builder.setView(textview);
            builder.setPositiveButton(getString(R.string.go_to_settings),
                    new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialoginterface, int i) {
                            dialoginterface.dismiss();
                            Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                            startActivityForResult(intent, 0);
                            return;

                        }

                    });
            builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialoginterface, int i) {
                    dialoginterface.dismiss();
                }

            });
            builder.create().show();
        }
    }

}

From source file:com.tonyandr.caminoguideoff.map.MapActivity.java

private void checkGPS() {
    LocationManager lm = (LocationManager) getSystemService(LOCATION_SERVICE);
    if (!lm.isProviderEnabled(LocationManager.GPS_PROVIDER)
            && !lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
        // Build the alert dialog
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Where are you?");
        builder.setMessage("Please enable Location Services and GPS");
        builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            @Override//from   w  w w.ja  va2s .  c o m
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
            }
        });
        builder.setPositiveButton("Enable", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialogInterface, int i) {
                // Show location settings when the user acknowledges the alert dialog
                Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                startActivity(intent);
            }
        });
        Dialog alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(false);
        alertDialog.show();
    }
}

From source file:au.org.ala.fielddata.mobile.MobileFieldDataDashboard.java

private void showNoGpsDialog() {
    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Enable GPS?").setMessage(
            "The GPS on this device is currently disabled, do you want to enable it? \nEnabling GPS will allow accurate survey locations to be recorded.")
            .setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(final DialogInterface dialog, final int id) {
                    startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
                }//w w w  . ja v a2  s .  com
            }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                public void onClick(final DialogInterface dialog, final int id) {
                    dialog.cancel();
                }
            });
    builder.create().show();
    askedAboutGPS = true;
}