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:me.ububble.speakall.fragment.ConversationGroupFragment.java

public void checkCountryLocation(final boolean gpsProvider, final boolean netProvider) {
    getActivity().runOnUiThread(new Runnable() {
        @Override/*w  w  w .jav a2  s .  c  om*/
        public void run() {
            boolean gpsEnabled = false;
            boolean networkEnabled = false;
            if (gpsProvider) {
                gpsEnabled = milocManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
            }
            if (netProvider) {
                networkEnabled = milocManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
            }
            if (gpsProvider && netProvider) {
                if (!gpsEnabled && !networkEnabled) {
                    LayoutInflater dialogInflater = (LayoutInflater) activity
                            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    dialogView = dialogInflater.inflate(R.layout.null_contact_dialog, null);
                    TextView mensaje = (TextView) dialogView.findViewById(R.id.dialog_add_contact);
                    mensaje.setText(getString(R.string.location_services));
                    final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity)
                            .setView(dialogView).setCancelable(true)
                            .setPositiveButton(R.string.add_contact_yes, null)
                            .setNegativeButton(R.string.add_contact_no, null);
                    finderDialog = dialogBuilder.show();
                    finderDialog.setCanceledOnTouchOutside(true);
                    finderDialog.getButton(DialogInterface.BUTTON_POSITIVE)
                            .setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    finderDialog.dismiss();
                                    System.gc();
                                    dontClose = true;
                                    ((MainActivity) activity).dontClose = true;
                                    Intent intent = new Intent(
                                            android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                                    startActivityForResult(intent, 45);
                                }
                            });
                    finderDialog.getButton(DialogInterface.BUTTON_NEGATIVE)
                            .setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    finderDialog.dismiss();
                                }
                            });
                } else {
                    milocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
                            ConversationGroupFragment.this);
                    milocManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
                            ConversationGroupFragment.this);
                }
            }
        }
    });
}