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.yoval.community.chatapp.DistanceActivity.java

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

    displayLocationSettingsRequest(getApplicationContext());

    if (googleServicesAvalaible()) {

        //Toast.makeText(this, "Perfect", Toast.LENGTH_LONG).show();
        initMap();//from w  ww. j av a  2s.  c o m
    } else {
        Toast.makeText(this, "Play services problem", Toast.LENGTH_LONG).show();
    }

    //Check for WIfi services enabled
    WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    if (!wifi.isWifiEnabled()) {
        showWifiRequest();
    }

    CustomizedLocationListener locationListener = new CustomizedLocationListener(getApplicationContext());
    locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);

    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.MAPS_RECEIVE) != PackageManager.PERMISSION_GRANTED) {

        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 5 * 60 * 1000, 10,
                locationListener);
    }

    if (FirebaseAuth.getInstance().getCurrentUser() == null) {
        // Start sign in/sign up activity
        startActivityForResult(AuthUI.getInstance().createSignInIntentBuilder().build(), SIGN_IN_REQUEST_CODE);
    } else {
        // User is already signed in. Therefore, display
        // a welcome Toast
        Toast.makeText(this,
                R.string.Bienvenue + " " + FirebaseAuth.getInstance().getCurrentUser().getDisplayName(),
                Toast.LENGTH_LONG).show();
    }

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbarDistance);
    setSupportActionBar(toolbar);

    SeekBar distanceBar = (SeekBar) findViewById(R.id.seekBarDistance); // make seekbar object
    distanceBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            // TODO Auto-generated method stub
            TextView textViewDistance = (TextView) findViewById(R.id.textViewDistance);
            textViewDistance.setText(progress + " Km");
            radius = progress;
            SaveUserInformations(radius);
            updateZoomMap();

        }
    });

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.distNext);

    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            goToDetailView();
        }
    });

    // ATTENTION: This was auto-generated to implement the App Indexing API.
    // See https://g.co/AppIndexing/AndroidStudio for more information.
    client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
}

From source file:com.example.get_location.Get_location.java

@Override
protected void onStart() {
    super.onStart();

    // Check if the GPS setting is currently enabled on the device.
    // This verification should be done during onStart() because the system calls this method
    // when the user returns to the activity, which ensures the desired location provider is
    // enabled each time the activity resumes from the stopped state.
    LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    final boolean gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);

    if (!gpsEnabled) {
        // Build an alert dialog here that requests that the user enable
        // the location services, then when the user clicks the "OK" button,
        // call enableLocationSettings()
    }//from www.jav a2s  .  c  o m
}

From source file:carsharing.starter.automotive.iot.ibm.com.mobilestarterapp.AnalyzeMyDriving.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.activity_analyze_my_driving, container, false);

    // Get Google Maps Setup
    final SupportMapFragment mapFragment = (SupportMapFragment) this.getChildFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);

    final AppCompatActivity activity = (AppCompatActivity) getActivity();

    // Retrieve a refrence of the location manager on Android from the location service
    locationManager = (LocationManager) activity.getSystemService(Context.LOCATION_SERVICE);
    // Get the best location provider available from the location manager
    provider = locationManager.getBestProvider(new Criteria(), false);

    // Setting up the app action bar at the top
    final ActionBar supportActionBar = activity.getSupportActionBar();
    // Show the back arrow when user navigates to other screens than home
    supportActionBar.setDisplayHomeAsUpEnabled(true);
    supportActionBar.setTitle("Setting up...");

    // Grab the "Start Driving" image from the "res/drawable" folder
    // And create an image button using it
    startDriving = (ImageButton) view.findViewById(R.id.imageButton);
    // When user clicks on the button, run this function
    startDriving.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Log to the console
            Log.i("Button Clicked", "Start Driving");

            // If the user hasn't started driving
            if (!startedDriving) {
                supportActionBar.setTitle("Preparing for this trip...");

                // The UI thread solely deals with the user interface and can execute tasks on it
                API.runInAsyncUIThread(new Runnable() {
                    @Override// w ww.  j  a  v a  2 s  . com
                    public void run() {
                        if (startDrive(deviceID)) {
                            // Keep the screen Awake (do not lock automatically or dim)
                            // https://developer.android.com/training/scheduling/wakelock.html
                            AnalyzeMyDriving.this.getActivity().getWindow()
                                    .addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

                            reserveCar();

                            // Change the "Start Driving" to "End Driving"
                            startDriving.setImageResource(R.drawable.enddriving);

                            transmissionCount = 0;

                            supportActionBar.setTitle("Please start driving safely.");
                        } else {
                            // Show a toast to the user
                            Toast.makeText(activity.getApplicationContext(),
                                    "Failed to connect to IoT Platform.", Toast.LENGTH_SHORT).show();

                            supportActionBar.setTitle("Check server connection.");
                        }
                    }
                }, activity);
            } else {
                startedDriving = false;

                supportActionBar.setTitle("Completing the trip...");

                // The UI thread solely deals with the user interface and can execute tasks on it
                API.runInAsyncUIThread(new Runnable() {
                    @Override
                    public void run() {
                        // Complete the reservation on the server
                        completeReservation(reservationId[0], false);

                        // Change the button image back to "Start Driving"
                        startDriving.setImageResource(R.drawable.startdriving);

                        // No longer need to keep the screen awake
                        AnalyzeMyDriving.this.getActivity().getWindow()
                                .clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
                    }
                }, activity);
            }
        }
    });

    this.view = view;
    return view;
}

From source file:net.openwatch.acluaz.fragment.FormFragment.java

public JSONObject toJson(ViewGroup container, JSONObject json) {
    String TAG = "FormFragment-ToJSON";
    if (container == null) {
        Log.e(TAG, "null container passed to toJson");
        return new JSONObject();
    }//from   w w w.j a  v a2  s.c  o  m

    if (json == null)
        json = new JSONObject();
    View view;
    for (int x = 0; x < container.getChildCount(); x++) {
        view = container.getChildAt(x);

        if (EditText.class.isInstance(view)) {
            if (view.getTag() != null) {
                if (((EditText) view).getText().toString().compareTo("") == 0)
                    continue; // skip blank input
                try {
                    Log.i(TAG, "Mapping: " + view.getTag().toString() + " value: "
                            + ((EditText) view).getText().toString());
                    if (view.getTag().toString().compareTo(getString(R.string.zipcode_tag)) == 0)
                        json.put(view.getTag().toString(),
                                Integer.parseInt(((EditText) view).getText().toString()));
                    else
                        json.put(view.getTag().toString(), ((EditText) view).getText().toString());
                } catch (JSONException e) {
                    Log.e(TAG, "Error jsonifying text input");
                    e.printStackTrace();
                }

            }
        } else if (CompoundButton.class.isAssignableFrom(view.getClass())) {
            if (view.getTag() != null) {
                // if location toggle, bundle location
                if (((String) view.getTag()).compareTo(getString(R.string.device_location_tag)) == 0
                        && view.getTag(R.id.view_tag) != null) {
                    if (((CompoundButton) view).isChecked()) {
                        try {
                            json.put(getString(R.string.device_lat),
                                    ((Location) view.getTag(R.id.view_tag)).getLatitude());
                            json.put(getString(R.string.device_lon),
                                    ((Location) view.getTag(R.id.view_tag)).getLongitude());
                        } catch (JSONException e) {
                            Log.e(TAG, "Error jsonifying toggle input");
                            e.printStackTrace();
                        }
                    }
                } else if (((String) view.getTag()).compareTo(getString(R.string.device_location_tag)) == 0
                        && view.getTag(R.id.view_tag) == null) {
                    // no location tagged, get last known
                    LocationManager lm = (LocationManager) container.getContext()
                            .getSystemService(Context.LOCATION_SERVICE);
                    Location last = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
                    try {
                        json.put(getString(R.string.device_lat), last.getLatitude());
                        json.put(getString(R.string.device_lon), last.getLongitude());
                    } catch (JSONException e) {
                        Log.e(TAG, "Error jsonifying last location");
                        e.printStackTrace();
                    } catch (NullPointerException e2) {
                        Log.e(TAG, "No current or historical location info on this device");
                    }
                }

            }
        }

        // combine date and time fields into a single datetime
        if (json.has(getString(R.string.date_tag)) && json.has(getString(R.string.time_tag))) {
            Log.i(TAG, "found date and time tag, let's smush 'em");
            try {
                //TESTING
                //String datetime = combineDateAndTime(json.getString(getString(R.string.date_tag)), json.getString(getString(R.string.time_tag)));
                //Log.i(TAG,"datetime: " + datetime);
                json.put(getString(R.string.date_tag),
                        combineDateAndTime(json.getString(getString(R.string.date_tag)),
                                json.getString(getString(R.string.time_tag))));
                Log.i(TAG, json.toString());
                //json.remove(getString(R.string.date_tag));
                json.remove(getString(R.string.time_tag));
            } catch (JSONException e) {
                Log.e(TAG, "Error creating json datetime field from date and time");
                e.printStackTrace();
            }
        }

    }
    Log.i(TAG, "toJson: " + json.toString());
    return json;

}

From source file:com.riverspart.location.ui.PlaceActivity.java

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

    // Inflate the layout
    setContentView(R.layout.location_main);

    // Get a handle to the Fragments
    placeListFragment = (PlaceListFragment) getSupportFragmentManager().findFragmentById(R.id.list_fragment);
    checkinFragment = (CheckinFragment) getSupportFragmentManager().findFragmentById(R.id.checkin_fragment);

    // Get references to the managers
    packageManager = getPackageManager();
    notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    // Get a reference to the Shared Preferences and a Shared Preference Editor.
    prefs = getSharedPreferences(PlacesConstants.SHARED_PREFERENCE_FILE, Context.MODE_PRIVATE);
    prefsEditor = prefs.edit();/* w  ww  .ja  v  a2s.  com*/

    // Instantiate a SharedPreferenceSaver class based on the available platform version.
    // This will be used to save shared preferences
    sharedPreferenceSaver = PlatformSpecificImplementationFactory.getSharedPreferenceSaver(this);

    // Save that we've been run once.
    prefsEditor.putBoolean(PlacesConstants.SP_KEY_RUN_ONCE, true);
    sharedPreferenceSaver.savePreferences(prefsEditor, false);

    // Specify the Criteria to use when requesting location updates while the application is Active
    criteria = new Criteria();
    if (PlacesConstants.USE_GPS_WHEN_ACTIVITY_VISIBLE)
        criteria.setAccuracy(Criteria.ACCURACY_FINE);
    else
        criteria.setPowerRequirement(Criteria.POWER_LOW);

    // Setup the location update Pending Intents
    Intent activeIntent = new Intent(this, LocationChangedReceiver.class);
    locationListenerPendingIntent = PendingIntent.getBroadcast(this, 0, activeIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    Intent passiveIntent = new Intent(this, PassiveLocationChangedReceiver.class);
    locationListenerPassivePendingIntent = PendingIntent.getBroadcast(this, 0, passiveIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    // Instantiate a LastLocationFinder class.
    // This will be used to find the last known location when the application starts.
    lastLocationFinder = PlatformSpecificImplementationFactory.getLastLocationFinder(this);
    lastLocationFinder.setChangedLocationListener(oneShotLastLocationUpdateListener);

    // Instantiate a Location Update Requester class based on the available platform version.
    // This will be used to request location updates.
    locationUpdateRequester = PlatformSpecificImplementationFactory.getLocationUpdateRequester(locationManager);

    // Create an Intent Filter to listen for checkins
    newCheckinReceiverName = new ComponentName(this, NewCheckinReceiver.class);
    newCheckinFilter = new IntentFilter(PlacesConstants.NEW_CHECKIN_ACTION);

    // Check to see if an Place ID has been specified in the launch Intent.
    // If so, we should display the details for the specified venue.
    if (getIntent().hasExtra(PlacesConstants.EXTRA_KEY_ID)) {
        Intent intent = getIntent();
        String key = intent.getStringExtra(PlacesConstants.EXTRA_KEY_ID);
        if (key != null) {
            selectDetail(null, key);
            // Remove the ID from the Intent (so that a resume doesn't reselect).
            intent.removeExtra(PlacesConstants.EXTRA_KEY_ID);
            setIntent(intent);
        }
    }
}

From source file:com.airbop.library.simple.CommonUtilities.java

/**
 * Get the last location from the LocationManager, if it's available, if not
 * return null.//ww w .ja  v  a 2s.c  o m
 * @param appContext
 * @return
 */
public static Location getLastLocation(final Context appContext) {
    Location location = null;
    if (true) {
        Criteria criteria = getCriteria();
        LocationManager locationManager = (LocationManager) appContext
                .getSystemService(Context.LOCATION_SERVICE);
        if (locationManager != null) {
            String provider = locationManager.getBestProvider(criteria, true);
            if (provider != null) {
                location = locationManager.getLastKnownLocation(provider);

                if (location != null) {
                    displayMessage(appContext, String.format(AirBopStrings.airbop_got_last_location,
                            location.getLatitude(), location.getLongitude()));
                }
            }
        }
    }
    return location;
}

From source file:kn.uni.gis.foxhunt.GameActivity.java

private void registerOnGPS() {
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    if (!!!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
        Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
        startActivity(intent);/*from w ww.  j a  va 2  s.c o m*/
    }
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 500, 2f, this);
    if (SettingsContext.getInstance().isUseNetwork()) {
        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 500, 2f, this);
    }
}

From source file:com.cmput301w17t07.moody.EditMoodActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    UserController userController = new UserController();
    userName = userController.readUsername(EditMoodActivity.this).toString();
    setContentView(R.layout.activity_edit_mood);
    setUpMenuBar(this);

    // get the mood object that was selected
    Intent intent = getIntent();//from   ww w .  j a  v a 2  s . c  o m
    editMood = (Mood) intent.getSerializableExtra("editMood");
    date = editMood.getDate();
    bitmapImage = (Bitmap) intent.getParcelableExtra("bitmapback");
    editBitmapImage = bitmapImage;
    deletedPic = (int) intent.getExtras().getInt("bitmapdelete");
    latitude = editMood.getLatitude();
    longitude = editMood.getLongitude();
    image = (ImageView) findViewById(R.id.editImageView);
    final TextView location = (TextView) findViewById(R.id.locationText);
    address = editMood.getDisplayLocation();
    location.setText(address);

    if (latitude == 0 && longitude == 0) {
        location1 = null;
    }
    displayAttributes();
    if (deletedPic == 1) {
        image.setImageBitmap(null);
    }

    //set up the button and imageButton
    ImageButton editLocation = (ImageButton) findViewById(R.id.location);
    editLocation.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            locationText = (TextView) findViewById(R.id.locationText);
            locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
            //check available tools
            List<String> locationList = locationManager.getProviders(true);
            if (locationList.contains(LocationManager.GPS_PROVIDER)) {
                provider = LocationManager.GPS_PROVIDER;
            } else if (locationList.contains(LocationManager.NETWORK_PROVIDER)) {
                provider = LocationManager.NETWORK_PROVIDER;
            } else {
                Toast.makeText(getApplicationContext(), "Please check your permissions", Toast.LENGTH_LONG)
                        .show();
            }
            //check the permission
            if (ActivityCompat.checkSelfPermission(getApplicationContext(),
                    android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
                    && ActivityCompat.checkSelfPermission(getApplicationContext(),
                            android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                // TODO: Consider calling
                Toast.makeText(getApplicationContext(),
                        "Getting location failed, Please check the application permissions", Toast.LENGTH_SHORT)
                        .show();
                return;
            }

            location1 = locationManager.getLastKnownLocation(provider);
            if (location1 == null) {
                latitude = 0;
                longitude = 0;
            } else {
                latitude = location1.getLatitude();
                longitude = location1.getLongitude();
            }

            //get the location name by latitude and longitude
            Geocoder gcd = new Geocoder(EditMoodActivity.this, Locale.getDefault());
            try {
                List<Address> addresses = gcd.getFromLocation(latitude, longitude, 1);

                if (addresses.size() > 0)
                    address = "  " + addresses.get(0).getFeatureName() + " "
                            + addresses.get(0).getThoroughfare() + ", " + addresses.get(0).getLocality() + ", "
                            + addresses.get(0).getAdminArea() + ", " + addresses.get(0).getCountryCode();
                location.setText(address);
            } catch (Exception e) {
                e.printStackTrace();
            }

            final ImageButton deleteLocation = (ImageButton) findViewById(R.id.deleteLocation);
            deleteLocation.setVisibility(View.VISIBLE);
            deleteLocation.setEnabled(true);
        }
    });

    editLocation.setOnLongClickListener(new View.OnLongClickListener() {
        public boolean onLongClick(View view) {
            moodMessage_text = Description.getText().toString();
            editMood.setMoodMessage(moodMessage_text);
            editMood.setDate(date);
            Intent editLocation = new Intent(EditMoodActivity.this, EditLocation.class);
            editLocation.putExtra("EditMood", editMood);
            editLocation.putExtra("bitmap", compress(editBitmapImage));
            startActivity(editLocation);
            return true;
        }
    });

    final ImageButton deleteLocation = (ImageButton) findViewById(R.id.deleteLocation);
    deleteLocation.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            location1 = null;
            locationText = (TextView) findViewById(R.id.locationText);
            address = null;
            locationText.setText(address);
            latitude = 0;
            longitude = 0;
            deleteLocation.setVisibility(View.INVISIBLE);
            deleteLocation.setEnabled(false);
        }
    });

    ImageButton editCameraButton = (ImageButton) findViewById(R.id.editCamera);
    editCameraButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            try {
                Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
                startActivityForResult(intent, 1);
            } catch (Exception e) {
                Intent intent = new Intent(getApplicationContext(), EditMoodActivity.class);
                startActivity(intent);
            }
        }
    });

    editCameraButton.setOnLongClickListener(new View.OnLongClickListener() {
        public boolean onLongClick(View view) {
            try {
                Intent intent = new Intent("android.intent.action.PICK");
                intent.setType("image/*");
                startActivityForResult(intent, 0);
            } catch (Exception e) {
                Intent intent = new Intent(getApplicationContext(), EditMoodActivity.class);
                startActivity(intent);
            }
            return true;
        }
    });

    ImageButton PickerButton = (ImageButton) findViewById(R.id.EditDate);
    PickerButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            innit();
            TimeDialog.show();
        }
    });
    Button submitButton = (Button) findViewById(R.id.button5);
    submitButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            moodMessage_text = Description.getText().toString();
            MoodController moodController = new MoodController();
            editBitmapImage = bitmapImage;
            AchievementManager.initManager(EditMoodActivity.this);
            AchievementController achievementController = new AchievementController();
            achievements = achievementController.getAchievements();
            achievements.firstTimeEditFlag = 1;
            achievementController.saveAchievements();

            if (!moodController.editMood(EmotionText, userName, moodMessage_text, latitude, longitude,
                    editBitmapImage, SocialSituation, date, address, editMood, EditMoodActivity.this)) {
                Toast.makeText(EditMoodActivity.this, "Mood message length is too long. Please try again",
                        Toast.LENGTH_SHORT).show();
            } else {
                Intent intent = new Intent(EditMoodActivity.this, TimelineActivity.class);
                startActivity(intent);
                finish();
            }
        }
    });

    // TODO button needs only display when image present in Mood
    final ImageButton deletePicture = (ImageButton) findViewById(R.id.deletePicture);
    if (editBitmapImage == null || deletedPic == 1) {
        deletePicture.setVisibility(View.INVISIBLE);
        deletePicture.setEnabled(false);
    }
    deletePicture.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            bitmapImage = null;
            editBitmapImage = null;
            image.setImageDrawable(null);
            deletePicture.setVisibility(View.INVISIBLE);
            deletePicture.setEnabled(false);
        }
    });
}

From source file:com.amazonaws.devicefarm.android.referenceapp.Fragments.FixturesFragment.java

/**
 * Updates the GPS status//from  ww w  . jav  a2  s . c  o  m
 */
private void updateGPSStatusDisplay() {
    final LocationManager locationManager = (LocationManager) getActivity()
            .getSystemService(Context.LOCATION_SERVICE);
    gps.setText(Boolean.toString(locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)));
}

From source file:com.xmobileapp.rockplayer.LastFmEventImporter.java

/*********************************
 * // w ww .  ja v  a  2s.  c o m
 * Constructor
 * @param context
 * 
 *********************************/
public LastFmEventImporter(Context context) {
    this.context = context;

    Log.i("LASTFMEVENT", "creating-------------------------");
    /*
     * Check for Internet Connection (Through whichever interface)
     */
    ConnectivityManager connManager = (ConnectivityManager) ((RockPlayer) context)
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo netInfo = connManager.getActiveNetworkInfo();
    /******* EMULATOR HACK - false condition needs to be removed *****/
    //if (false && (netInfo == null || !netInfo.isConnected())){
    if ((netInfo == null || !netInfo.isConnected())) {
        Bundle data = new Bundle();
        data.putString("info", "No Internet Connection");
        Message msg = new Message();
        msg.setData(data);
        ((RockPlayer) context).analyseConcertInfoHandler.sendMessage(msg);
        return;
    }

    /*
     * Get location
     */
    MIN_UPDATE_INTVL = 5 * 24 * 60 * 60 * 1000; // 5 days
    SPREAD_INTVL = 21 * 24 * 60 * 60 * 1000; // 21 days;
    Criteria criteria = new Criteria();
    criteria.setAccuracy(Criteria.ACCURACY_COARSE);
    criteria.setPowerRequirement(Criteria.POWER_LOW);
    LocationManager locManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    if (locManager.getBestProvider(criteria, true) != null)
        myLocation = locManager.getLastKnownLocation(locManager.getBestProvider(criteria, true));
    else {
        myLocation = new Location("gps");
        myLocation.setLatitude(47.100301);
        myLocation.setLongitude(-119.982465);
    }

    /*
     * Get preferred distance
     */
    //      SharedPreferences prefs = ((Filex) context).getSharedPreferences(((Filex) context).PREFS_NAME, 0);
    RockOnPreferenceManager prefs = new RockOnPreferenceManager(((RockPlayer) context).FILEX_PREFERENCES_PATH);
    concertRadius = prefs.getLong("ConcertRadius", (long) (((RockPlayer) context).CONCERT_RADIUS_DEFAULT));

    //myLocation =  locManager.getLastKnownLocation(locManager.getBestProvider(Criteria.POWER_LOW, true));

    //      try {
    //         getArtistEvents();
    //      } catch (SAXException e) {
    //         e.printStackTrace();
    //      } catch (ParserConfigurationException e) {
    //         e.printStackTrace();
    //      }
}