Example usage for android.content Context LOCATION_SERVICE

List of usage examples for android.content Context LOCATION_SERVICE

Introduction

In this page you can find the example usage for android.content Context LOCATION_SERVICE.

Prototype

String LOCATION_SERVICE

To view the source code for android.content Context LOCATION_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.location.LocationManager for controlling location updates.

Usage

From source file:com.hit.jj.mapshow.RoutingActivity.java

/**
 * ??/*from   w w w.ja v  a2 s  .  c o m*/
 */
private void init() {
    manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    //???
    initialEnv();
    initialTts();

    if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
        buildAlertMessageNoGps();
    }
    // Retrieve the map and initial extent from XML layout
    map = (MapView) findViewById(R.id.map);
    // Add tiled layer to MapView
    tileLayer = new ArcGISDynamicMapServiceLayer(
            "http://58.199.250.101:6080/arcgis/rest/services/xmut/map/MapServer");
    map.addLayer(tileLayer);
    mFeatureLayer = new ArcGISFeatureLayer(
            "http://58.199.250.101:6080/arcgis/rest/services/xm/path1/FeatureServer/0",
            ArcGISFeatureLayer.MODE.SELECTION);
    map.addLayer(mFeatureLayer);
    Callout mapCallout = map.getCallout();
    mapCallout.hide();
    // Add the route graphic layer (shows the full route)
    routeLayer = new GraphicsLayer();
    map.addLayer(routeLayer);
    mFeatureLayer.getFields();
    graphicsLayer = new GraphicsLayer();
    map.addLayer(graphicsLayer);
    MyOnSingleTapListener listener = new MyOnSingleTapListener(this);
    map.setOnSingleTapListener(listener);
    try {
        mRouteTask = RouteTask.createOnlineRouteTask(
                "http://58.199.250.101:6080/arcgis/rest/services/xmut/path2/NAServer/path", null);

    } catch (Exception e1) {
        e1.printStackTrace();
    }
    // Add the hidden segments layer (for highlighting route segments)
    hiddenSegmentsLayer = new GraphicsLayer();
    map.addLayer(hiddenSegmentsLayer);

    // Make the segmentHider symbol "invisible"
    segmentHider.setAlpha(1);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    img_cancel = (ImageView) findViewById(R.id.iv_cancel);
    img_currLocation = (ImageView) findViewById(R.id.iv_myLocation);
    img_getDirections = (ImageView) findViewById(R.id.iv_getDirections);
    mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
    img_speak = (ImageView) findViewById(R.id.iv_speak);
    img_showDirections = (ImageView) findViewById(R.id.direction);
    // Get the location display manager and start reading location. Don't
    // auto-pan
    // to center our position
    ldm = map.getLocationDisplayManager();
    ldm.setLocationListener(new MyLocationListener());
    ldm.start();
    ldm.setAutoPanMode(AutoPanMode.LOCATION);

    // Set the directionsLabel with initial instructions.
    directionsLabel = (TextView) findViewById(R.id.directionsLabel);
    directionsLabel.setText(getString(R.string.route_label));
}

From source file:com.findcab.driver.activity.Signup.java

/**
 * ?GPS?//ww w  .  ja  va 2s  . co m
 */
private void initLocation() {

    LocationManager locationManager;
    String serviceName = Context.LOCATION_SERVICE;
    locationManager = (LocationManager) this.getSystemService(serviceName);
    // ?
    Criteria criteria = new Criteria();
    criteria.setAccuracy(Criteria.ACCURACY_FINE);
    criteria.setAltitudeRequired(false);
    criteria.setBearingRequired(false);
    criteria.setCostAllowed(true);
    criteria.setPowerRequirement(Criteria.POWER_LOW);

    String provider = locationManager.getBestProvider(criteria, true);
    Location location = locationManager.getLastKnownLocation(provider);
    if (location != null) {

        lat = location.getLatitude();
        lng = location.getLongitude();

    }
}

From source file:com.luke.lukef.lukeapp.tools.LukeUtils.java

/**
 * Checks the current GPS status, if GPS is not enabled then calls
 * {@link LukeUtils#alertDialogBuilder(Context, String, String)} to create a prompt for the user
 * to enable GPS./*from   w ww  . jav a2  s  .  c  o  m*/
 *
 * @param context Context, needed to create the alert.
 * @return <b>true</b> if the GPS is enabled, <b>false</b> if it's not.
 */
public static boolean checkGpsStatus(Context context) {
    final LocationManager manager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
        alertDialogBuilder(context, noGps, android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
        return false;
    } else {
        return true;
    }
}

From source file:com.nextgis.maplibui.fragment.CompassFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (null == getParentFragment()) {
        setRetainInstance(true);// w ww. j  a  va  2s  .  c o  m
    }

    // reference to vibrator service
    mDeclination = 0;
    mVibrator = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE);
    mSensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE);

    if (!PermissionUtil.hasPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION)
            || !PermissionUtil.hasPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION))
        return;

    if (mCurrentLocation == null) {
        LocationManager locationManager = (LocationManager) getActivity()
                .getSystemService(Context.LOCATION_SERVICE);
        mCurrentLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

        if (mCurrentLocation == null) {
            mCurrentLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
        }
    }

    if (mCurrentLocation != null)
        mDeclination = getDeclination(mCurrentLocation, System.currentTimeMillis());
}

From source file:com.towson.wavyleaf.Sighting.java

protected void init() {
    getWindow().setBackgroundDrawable(null);
    Typeface tf_light = Typeface.createFromAsset(getAssets(), "fonts/roboto_light.ttf");
    Typeface tf_bold = Typeface.createFromAsset(getAssets(), "fonts/roboto_bold.ttf");

    tvlat = (TextView) findViewById(R.id.tv_latitude);
    tvlong = (TextView) findViewById(R.id.tv_longitude);
    tvpicnotes = (TextView) findViewById(R.id.tv_picturenotes);
    tvper = (TextView) findViewById(R.id.tv_percentageseen);
    tvper_summary = (TextView) findViewById(R.id.tv_percentageseen_summary);
    tvcoor = (TextView) findViewById(R.id.tv_coordinates);
    tvarea = (TextView) findViewById(R.id.tv_areainfested);
    tvarea_summary = (TextView) findViewById(R.id.tv_areainfested_summary);
    tv_treatment = (TextView) findViewById(R.id.tv_treatment);
    notes = (EditText) findViewById(R.id.notes);
    etarea = (EditText) findViewById(R.id.et_areainfested);
    b1 = (ToggleButton) findViewById(R.id.bu_1);
    b2 = (ToggleButton) findViewById(R.id.bu_2);
    b3 = (ToggleButton) findViewById(R.id.bu_3);
    b4 = (ToggleButton) findViewById(R.id.bu_4);
    b5 = (ToggleButton) findViewById(R.id.bu_5);
    b6 = (ToggleButton) findViewById(R.id.bu_6);
    cb = (CheckBox) findViewById(R.id.cb_confirm);
    rg = (RadioGroup) findViewById(R.id.toggleGroup);
    sp = (Spinner) findViewById(R.id.sp_areainfested);
    sp_treatment = (Spinner) findViewById(R.id.sp_treatment);
    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    locationData = (LocationApplication) getApplication();
    currentEditableLocation = locationData.getLocation();

    updateLocationTimer = new Timer();
    TimerTask updateLocationTask = new TimerTask() {
        @Override//from  w w w  .  jav  a 2 s.co  m
        public void run() {
            checkLocation();
        }
    };
    updateLocationTimer.scheduleAtFixedRate(updateLocationTask, 0, FIVE_SECONDS);

    // Listener for EditText in Area Infested
    etarea.addTextChangedListener(new TextWatcher() {
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (etarea.getText().length() == 0) {
                tvarea_summary.setText("");
            } else if (etarea.getText().toString().contains("-")) { // Negative number
                etarea.getEditableText().clear();
                Toast.makeText(getApplicationContext(), "Negative values not allowed", Toast.LENGTH_SHORT)
                        .show();
            } else {
                tvarea_summary.setText(etarea.getText() + " " + sp.getSelectedItem().toString());
            }
        }

        public void afterTextChanged(Editable s) {
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }
    });

    // Listener for spinner in Area Infested
    sp.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
        }

        @Override
        public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            if (etarea.getText().length() != 0)
                tvarea_summary.setText(etarea.getText() + " " + sp.getSelectedItem());
        }
    });

    // Adapter for area infested spinner
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.areainfested_array,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    sp.setAdapter(adapter);

    // Adapter for Treatment spinner
    ArrayAdapter<CharSequence> adapter2 = ArrayAdapter.createFromResource(this, R.array.treatment_array,
            android.R.layout.simple_spinner_item);
    adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    sp_treatment.setAdapter(adapter2);

    // Just to be safe
    cb.setChecked(false);

    // Set all the beautiful typefaces
    tvlat.setTypeface(tf_light);
    tvlong.setTypeface(tf_light);
    tvcoor.setTypeface(tf_bold);
    tvarea.setTypeface(tf_bold);
    tvarea_summary.setTypeface(tf_bold);
    tvper.setTypeface(tf_bold);
    tvper_summary.setTypeface(tf_bold);
    tvpicnotes.setTypeface(tf_bold);
    tv_treatment.setTypeface(tf_bold);
    cb.setTypeface(tf_light);
    b1.setTypeface(tf_light);
    b2.setTypeface(tf_light);
    b3.setTypeface(tf_light);
    b4.setTypeface(tf_light);
    b5.setTypeface(tf_light);
    b6.setTypeface(tf_light);

    if (!locationData.isSearching())
        findUsersLocation();

    ib = (ImageButton) findViewById(R.id.imagebutton_sighting);
    // Listener for camera button
    ib.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            takePicture();
        }
    });

    ib_percent = (ImageButton) findViewById(R.id.ib_percent);
    // Listener for help button in Percentage Infested category
    ib_percent.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            showDialog(HELP_PERCENT);
        }
    });

    ib_treatment = (ImageButton) findViewById(R.id.ib_treatment);
    // Listener for help button in Treatment catgeory
    ib_treatment.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            showDialog(HELP_TREATMENT);
            //            Toast.makeText(getApplicationContext(), "Specify the type of treatment that was done to this area", Toast.LENGTH_LONG).show();
        }
    });
}

From source file:com.facebook.react.modules.location.LocationModule.java

/**
 * Stop listening for location updates.//from   w ww .j a va  2 s  .  c om
 *
 * NB: this is not balanced with {@link #startObserving}: any number of calls to that method will
 * be canceled by just one call to this one.
 */
@ReactMethod
public void stopObserving() {
    LocationManager locationManager = (LocationManager) getReactApplicationContext()
            .getSystemService(Context.LOCATION_SERVICE);
    locationManager.removeUpdates(mLocationListener);
    mWatchedProvider = null;
}

From source file:de.bogutzky.psychophysiocollector.app.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    checkBtEnabled();//from  w  ww.j av  a 2s . com

    deviceNames = new ArrayList<>();
    arrayAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, deviceNames);
    setListAdapter(arrayAdapter);

    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

    textViewTimer = (TextView) findViewById(R.id.text_view_timer);
    textViewTimer.setVisibility(View.INVISIBLE);

    final SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE);
    selfReportInterval = sharedPref.getInt("selfReportInterval", 15);
    selfReportVariance = sharedPref.getInt("selfReportVariance", 30);

    localeString = this.getResources().getConfiguration().locale.getLanguage().substring(0, 2).toLowerCase();
    try {
        questionnaireFilenames = getAssets().list("questionnaires/" + localeString);
    } catch (IOException e) {
        e.printStackTrace();
    }
    questionnaireCount = questionnaireFilenames.length;

    if (questionnaireCount == 0) {
        Toast.makeText(this, R.string.no_questionnaires_available, Toast.LENGTH_SHORT).show();
        questionnaireFilePath = "";
    } else {
        int questionnaireSpinnerPosition = sharedPref.getInt("questionnaireSpinnerPosition", 0);
        questionnaireFilePath = "questionnaires/" + localeString + "/"
                + questionnaireFilenames[questionnaireSpinnerPosition];
    }

    activityName = sharedPref.getString("activityName", "");
    participantFirstName = sharedPref.getString("participantFirstName", "");
    participantLastName = sharedPref.getString("participantLastName", "");
    intervalConfigured = sharedPref.getBoolean("configureInterval", false);

    getListView().setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {

            final int index = position;

            AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
            builder.setCancelable(true);
            builder.setTitle(getString(R.string.delete));
            builder.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    deviceNames.remove(index);
                    getBluetoothAddresses().remove(index);
                    arrayAdapter.notifyDataSetChanged();
                    if (getBluetoothAddresses().size() == 0) {
                        connectMenuItem.setEnabled(false);
                    }
                    disconnectBioHarness();
                    disconnectAllShimmerImus();
                }
            });
            builder.create().show();
            return false;
        }
    });

    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
            && ContextCompat.checkSelfPermission(this,
                    Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this,
                new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE,
                        Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.BLUETOOTH_ADMIN,
                        Manifest.permission.ACCESS_COARSE_LOCATION },
                PERMISSIONS_REQUEST);

    }
}

From source file:com.example.android.location.BaselineActivity.java

/**
 * This sample demonstrates how to incorporate location based services in your app and
 * process location updates.  The app also shows how to convert lat/long coordinates to
 * human-readable addresses.//from w ww  .j  a  v  a2 s .  c o m
 */
@SuppressLint("NewApi")
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    fileOpen = false;
    // Restore apps state (if exists) after rotation.
    if (savedInstanceState != null) {
        mUseFine = savedInstanceState.getBoolean(KEY_FINE);
        mUseBoth = savedInstanceState.getBoolean(KEY_BOTH);
    } else {
        mUseFine = false;
        mUseBoth = false;
    }
    amanager = (AudioManager) getSystemService(AUDIO_SERVICE);

    tb = (ToggleButton) this.findViewById(R.id.tglSetStatus);

    tb.setChecked(fileOpen);
    mLatLng = (TextView) findViewById(R.id.latlng);
    mAddress = (TextView) findViewById(R.id.address);
    mSpeed = (TextView) findViewById(R.id.speed);
    avgSpeedView = (TextView) findViewById(R.id.avgspeedfield);
    avgPaceView = (TextView) findViewById(R.id.avgpacefield);
    mMinPace = (TextView) findViewById(R.id.minpaceIndicator);
    mMaxPace = (TextView) findViewById(R.id.maxpaceIndicator);
    mMaxPace.setText("0.0");
    mMinPace.setText("40.0");
    totalSpeeds = 0;
    measureCount = 0;
    averageSpeed = 0;

    logStartButton = (Button) findViewById(R.id.logStartButton);
    logStartButton.setOnClickListener(new StartButtonListener());

    logStopButton = (Button) findViewById(R.id.logStopButton);
    logStopButton.setOnClickListener(new StopButtonListener());

    // Receive location updates from the fine location provider (gps) only.
    mFineProviderButton = (Button) findViewById(R.id.provider_fine);
    // Receive location updates from both the fine (gps) and coarse (network) location
    // providers.
    mBothProviderButton = (Button) findViewById(R.id.provider_both);

    // The isPresent() helper method is only available on Gingerbread or above.
    mGeocoderAvailable = Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && Geocoder.isPresent();

    // Handler for updating text fields on the UI like the lat/long and address.
    mHandler = new Handler() {
        public void handleMessage(Message msg) {
            switch (msg.what) {
            case UPDATE_ADDRESS:
                mAddress.setText((String) msg.obj);
                break;
            case UPDATE_LATLNG:
                mLatLng.setText((String) msg.obj);
                break;
            case UPDATE_SPEED:
                mSpeed.setText((String) msg.obj);
                break;
            case UPDATE_AVG_SPEED:
                avgSpeedView.setText((String) msg.obj);
                break;
            case UPDATE_AVG_PACE:
                avgPaceView.setText((String) msg.obj);
                break;
            }
        }
    };
    // Get a reference to the LocationManager object.
    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    cal = Calendar.getInstance();
    seconds = (int) (cal.getTimeInMillis() / 1000);
    speedBuffer = new ArrayList<Double>();
    speedBuffer.add(0.0);
    speedBuffer.add(0.0);
    speedBuffer.add(0.0);
    gotInfinity = false;
}

From source file:com.detroitteatime.autocarfinder.Main.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mainLayout = (LinearLayout) this.getLayoutInflater().inflate(R.layout.main, null);

    setContentView(mainLayout);/*from w  ww  .  ja  va2  s .  c  o  m*/

    // Possible work around for market launches. See
    // http://code.google.com/p/android/issues/detail?id=2373
    // for more details. Essentially, the market launches the main activity
    // on top of other activities.
    // we never want this to happen. Instead, we check if we are the root
    // and if not, we finish.
    if (!isTaskRoot()) {
        final Intent intent = getIntent();
        final String intentAction = intent.getAction();
        if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && intentAction != null
                && intentAction.equals(Intent.ACTION_MAIN)) {
            // Log.w("My Code",
            // "Main Activity is not the root.  Finishing Main Activity instead of launching.");
            finish();
            return;
        }
    }

    // set up buttons
    start = (Button) findViewById(R.id.start);

    manual = (Button) findViewById(R.id.manual);
    // progress = (ProgressBar) findViewById(R.id.progressBar1);

    start.setOnClickListener(this);
    start.getBackground().setColorFilter(Color.parseColor(COLOR), PorterDuff.Mode.MULTIPLY);

    manual.setOnClickListener(this);
    manual.getBackground().setColorFilter(Color.parseColor(COLOR), PorterDuff.Mode.MULTIPLY);

    monitor = (FrameLayout) findViewById(R.id.frameLayout1);

    data1 = this.getSharedPreferences("storage", 0);
    editor1 = data1.edit();

    // firstTime = data1.getBoolean("first_time", true);

    editor1.putBoolean("first_time", false);
    editor1.commit();

    pi = PendingIntent.getActivity(this, 0, new Intent(this, Main.class), 0);

    data1 = getSharedPreferences("storage", 0);
    editor1 = data1.edit();

    // set a global layout listener which will be called when the layout
    // pass is completed and the view is drawn

    FragmentManager myFragmentManager = getSupportFragmentManager();
    mySupportMapFragment = (SupportMapFragment) myFragmentManager.findFragmentById(R.id.map);

    if (MapsInitializer.initialize(this) != ConnectionResult.SUCCESS) {
        Toast.makeText(this, "Map failed to initialize.", Toast.LENGTH_SHORT).show();

    }

    map = mySupportMapFragment.getMap();

    manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    // Define the criteria how to select the locatioin provider -> use
    // default
    criteria = new Criteria();
    criteria.setAccuracy(Criteria.ACCURACY_FINE);
    criteria.setAltitudeRequired(false);
    criteria.setBearingRequired(false);
    provider = manager.getBestProvider(criteria, false);
    manager.requestLocationUpdates(provider, 1000, 1, this);

    navigate = (Button) findViewById(R.id.navigate);
    navigate.setOnClickListener(this);

    type = (Button) findViewById(R.id.satellite);
    type.setOnClickListener(this);

}

From source file:com.wirelessmoves.cl.MainActivity.java

@SuppressWarnings("deprecation")
@Override/*w  w w .jav a 2s .c om*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    /* If saved variable state exists from last run, recover it */
    if (savedInstanceState != null) {
        NumberOfSignalStrengthUpdates = savedInstanceState.getLong("NumberOfSignalStrengthUpdates");

        LastCellId = savedInstanceState.getLong("LastCellId");
        NumberOfCellChanges = savedInstanceState.getLong("NumberOfCellChanges");

        LastLacId = savedInstanceState.getLong("LastLacId");
        NumberOfLacChanges = savedInstanceState.getLong("NumberOfLacChanges");

        PreviousCells = savedInstanceState.getLongArray("PreviousCells");
        PreviousCellsIndex = savedInstanceState.getInt("PreviousCellsIndex");
        NumberOfUniqueCellChanges = savedInstanceState.getLong("NumberOfUniqueCellChanges");

        outputDebugInfo = savedInstanceState.getBoolean("outputDebugInfo");

        CurrentLocationLong = savedInstanceState.getDouble("CurrentLocationLong");
        CurrentLocationLat = savedInstanceState.getDouble("CurrentLocationLat");

        /* attempt to restore the previous gps location information object */
        PrevLocation = (Location) getLastNonConfigurationInstance();

    } else {
        /* Initialize PreviousCells Array to defined values */
        for (int x = 0; x < PreviousCells.length; x++)
            PreviousCells[x] = 0;
    }

    /* Get a handle to the telephony manager service */
    /* A listener will be installed in the object from the onResume() method */
    MyListener = new MyPhoneStateListener();
    Tel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

    /* get a handle to the power manager and set a wake lock so the screen saver
     * is not activated after a timeout */
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "DoNotDimScreen");

    /* Get a handle to the location system for getting GPS information */
    locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
    gpsListener = new myLocationListener();
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, gpsListener);

}