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

  • Home
  • SEARCH
  • 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 1106733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:50:13+00:00 2026-05-17T01:50:13+00:00

I am using the following to mock my location in Android. public class GPSwork

  • 0

I am using the following to mock my location in Android.

public class GPSwork extends Activity implements LocationListener{
LocationManager locationManager;
String mocLocationProvider;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    mocLocationProvider = LocationManager.GPS_PROVIDER; 
    setLocation(28.574853,78.063201);
}

public void setLocation(double latitude, double longitude) {   
    locationManager.addTestProvider(mocLocationProvider, false, true, false, false, false, false, false, 0, 5);
    locationManager.setTestProviderEnabled(mocLocationProvider, true);
    locationManager.requestLocationUpdates(mocLocationProvider, 0, 0, this);
    Location loc = new Location(mocLocationProvider);
    loc.setTime(System.currentTimeMillis());
    loc.setLatitude(latitude);
    loc.setLongitude(longitude);
    locationManager.setTestProviderLocation(mocLocationProvider, loc);   
}

public void onLocationChanged(Location location) {
    // TODO Auto-generated method stub      
}

public void onProviderDisabled(String provider) {
    // TODO Auto-generated method stub

}

public void onProviderEnabled(String provider) {
    // TODO Auto-generated method stub      
}

public void onStatusChanged(String provider, int status, Bundle extras) {
    // TODO Auto-generated method stub      
}   
}

But it’s not working. I want to see it in real device and the bubble blinking in that location, but I didnt get anything. Please correct my code, and help me out. I used the permissions.

I want build an application similatiom to location spoofer.Actually when we open google maps it will show our current location with blue blinking at our location..similarly if i changed the coordinates i.e, latitude and latitude it has to show that am at that location with blue blinking,

![alt text][1]
this is the screen short..

My XML fine is

<?xml version="1.0" encoding="utf-8"?>

<com.google.android.maps.MapView 
    android:id="@+id/mapView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:apiKey="0Sy8vgJlQkFxcisUAkrxu3xN33dqFgBetCg4jxg"
    />

  • 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-05-17T01:50:14+00:00Added an answer on May 17, 2026 at 1:50 am

    This is a basic pattern for an app that uses google maps:

    public class MapsActivity extends MapActivity 
    {    
    
        MapView mapView;
    MapController mc;
    
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            mapView = (MapView)findViewById(R.id.mapView);
            //zoom controlls
            mc = mapView.getController();
            mc.setZoom(12);
            setContentView(R.layout.main);
        }
    
        @Override
        protected boolean isRouteDisplayed() {
            return false;
        }
    }
    

    In your AndroidManifest.xml file add:

     <uses-library android:name="com.google.android.maps" />
    

    and:

    <uses-permission android:name="android.permission.INTERNET" />
    

    To display your particular location add this to the onCreate method:

     String coordinates[] = {"1.352566007", "103.78921587"};
     double lat = Double.parseDouble(coordinates[0]);
     double lng = Double.parseDouble(coordinates[1]);
    
     p = new GeoPoint(
           (int) (lat * 1E6), 
           (int) (lng * 1E6));
    
     mc.animateTo(p);
     mc.setZoom(17); 
     mapView.invalidate();
    

    Finally you need to set your marker using a map overlay. Add the following class to your MapsActivity class:

    class MapOverlay extends com.google.android.maps.Overlay
        {
            @Override
            public boolean draw(Canvas canvas, MapView mapView, 
            boolean shadow, long when) 
            {
                super.draw(canvas, mapView, shadow);                   
    
                //---translate the GeoPoint to screen pixels---
                Point screenPts = new Point();
                mapView.getProjection().toPixels(p, screenPts);
    
                //---add the marker---
                Bitmap bmp = BitmapFactory.decodeResource(
                    getResources(), R.drawable.my_bubble);            
                canvas.drawBitmap(bmp, screenPts.x, screenPts.y-50, null);         
                return true;
            }
        } 
    

    In this draw method you can to some marker animation if you want to. Now you have to add the overlay to your map:

    //---Add a location marker---
     MapOverlay mapOverlay = new MapOverlay();
     List<Overlay> listOfOverlays = mapView.getOverlays();
     listOfOverlays.clear();
     listOfOverlays.add(mapOverlay);        
    
     mapView.invalidate();
    

    This is a quick overview. You will need a google api key to work with google maps api. A detailed tutorial on google maps api can be found here, Using Google Maps in Android

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

Sidebar

Related Questions

Using the following code I get a nice formatted string: Request.QueryString.ToString Gives me something
I am using following PHP code to connect to MS Access database: $odb_conn =
Using the following query and results, I'm looking for the most recent entry where
Using the following query: SELECT pe.prodtree_element_name_l, MAX(rs.resource_value) AS resource_value FROM prodtree_element pe LEFT JOIN
I am currently using the following command to upload my site content: scp -r
I'm using the following html to load dojo from Google's hosting. <script src=http://www.google.com/jsapi></script> <script
I'm using the following JavaScript code: <script language=JavaScript1.2 type=text/javascript> function CreateBookmarkLink(title, url) { if
I'm using the following code to query a database from my jsp, but I'd
I'm using the following in the web page but can't get a response from
I'm using the following method to send mail from Python using SMTP. Is it

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.