Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9134695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:42:33+00:00 2026-06-17T08:42:33+00:00

I want to run the sample codes for Google Maps API V2. I followed

  • 0

I want to run the sample codes for Google Maps API V2. I followed these steps, but a problem occurs. I have got a compiler error in the most Activities.

Error: The method activate(LocationSource.OnLocationChangedListener)
of type LocationSourceDemoActivity.LongPressLocationSource must
override a superclass method

In the following code these methods got an error:

public void activate(OnLocationChangedListener listener)
public void deactivate()
public void onMapLongClick(LatLng point)

Code:

package com.example.mapdemo;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.GoogleMap.OnMapLongClickListener;
import com.google.android.gms.maps.LocationSource;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;

import android.app.Activity;
import android.location.Location;
import android.os.Bundle;


/**
 * This shows how to use a custom location source.
 */
public class LocationSourceDemoActivity extends android.support.v4.app.FragmentActivity {
    /**
     * A {@link LocationSource} which reports a new location whenever a user long presses the map at
     * the point at which a user long pressed the map.
     */
    private static class LongPressLocationSource implements LocationSource, OnMapLongClickListener {
        private OnLocationChangedListener mListener;
    /**
     * Flag to keep track of the activity's lifecycle. This is not strictly necessary in this
     * case because onMapLongPress events don't occur while the activity containing the map is
     * paused but is included to demonstrate best practices (e.g., if a background service were
     * to be used).
     */
    private boolean mPaused;

    @Override
    public void activate(OnLocationChangedListener listener) {
        mListener = listener;
    }

    @Override
    public void deactivate() {
        mListener = null;
    }

    @Override
    public void onMapLongClick(LatLng point) {
        if (mListener != null && !mPaused) {
            Location location = new Location("LongPressLocationProvider");
            location.setLatitude(point.latitude);
            location.setLongitude(point.longitude);
            location.setAccuracy(100);
            mListener.onLocationChanged(location);
        }
    }

    public void onPause() {
        mPaused = true;
    }

    public void onResume() {
        mPaused = false;
    }

}

private LongPressLocationSource mLocationSource;

private GoogleMap mMap;

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

    mLocationSource = new LongPressLocationSource();

    setUpMapIfNeeded();
}

@Override
protected void onResume() {
    super.onResume();
    setUpMapIfNeeded();

    mLocationSource.onResume();
}

private void setUpMapIfNeeded() {
    // Do a null check to confirm that we have not already instantiated the map.
    if (mMap == null) {
        // Try to obtain the map from the SupportMapFragment.
        mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
        // Check if we were successful in obtaining the map.
        if (mMap != null) {
            setUpMap();
        }
    }
}

private void setUpMap() {
    mMap.setLocationSource(mLocationSource);
    mMap.setOnMapLongClickListener(mLocationSource);
    mMap.setMyLocationEnabled(true);
}

@Override
protected void onPause() {
    super.onPause();
    mLocationSource.onPause();
}
}

I attached the library and I haven’t skipped a step from Google’s guide.
I hope somebody of you can help me!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:42:33+00:00Added an answer on June 17, 2026 at 8:42 am

    Do you use a java 1.6 compliant compiler? The usage of the @Override annotation is different in 1.5 and 1.6 (see this answer).

    Right-click on your project node, choose “Properties”–>”Java Compiler”–>”Compiler compliance level” should be 1.6.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following sample code which doesn't seem to want to run. import
I want to start an Intent with a Google Maps fragment. The sample code
I'm experimenting with QtWebkit and Google Maps. The problem I've run into is calling
I've got a simple js/jquery function I want to run when the form is
I want to run Dojo/Dijit with the Google CDN: <script type=text/javascript src=http://ajax.googleapis.com/ajax/libs/dojo/1.3.2/dojo/dojo.xd.js> </script> I've
My students all have a Google account, but use different emails (like john@hotmail.com).I tried
I have recently changed domain name for a webapp I run on Google App
I have read and re-read this page, as well as run the samples: http://code.google.com/chrome/extensions/background_pages.html
I have a simple html form and jquery. and all I want to run
I want to run a simple test project in a subdirectory alias on our

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.