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 6846021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:34:19+00:00 2026-05-27T00:34:19+00:00

i wanna test GPS on my android emulator but i find my apps has

  • 0

i wanna test GPS on my android emulator but i find my apps has Error “Stopped Unexpectedly” when i try to run its on emulator.

here some sort of my codes
AndroidManifest.xml

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

and main.java

public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

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

    String provider = LocationManager.GPS_PROVIDER;
    Location location = locationManager.getLastKnownLocation(provider);
    updateWithNewLocation(location);
}

private void updateWithNewLocation(Location location){
    String latLongString;
    TextView myLocationText;
    myLocationText = (TextView)findViewById(R.id.myLocationText);
    if(location != null){
        double lat = location.getLatitude();
        double lng = location.getLongitude();
        latLongString = "Lat:" + lat + "\nLong:" + lng;
    }else{
        latLongString = "No location found";
    }
    myLocationText.setText("Your Current Position is: \n" + latLongString);
}

import on my main.java

import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.TextView;

would you tell me why my apps getting error “stopped unexpectedly” when i try to run its on my emulator ?

thanks for helping me 🙂

Error from tracing : “java.lang.NullPointerException”
i have been using DDMS to set long and lat to this:
long: 112.8010100
lat : -7.2950700

  • 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-27T00:34:20+00:00Added an answer on May 27, 2026 at 12:34 am

    You can mock the location in the emulator

    Providing Mock Location Data

    As you develop your application, you’ll certainly need to test how well
    your model for obtaining user location works. This is most easily done
    using a real Android-powered
    device. If, however, you don’t have a device, you can still test your
    location-based features by mocking location data in the Android emulator.
    There are three different ways to send your application mock location data:
    using Eclipse, DDMS, or the “geo” command in the emulator console.

    Note: Providing mock location data is injected as GPS location data,
    so you must request location updates from GPS_PROVIDER in order for mock
    location data to work.

    Using Eclipse

    Select Window > Show View > Other > Emulator Control.

    In the Emulator Control panel, enter GPS coordinates
    under Location Controls as individual lat/long coordinates,
    with a GPX file for route playback, or a KML file for
    multiple place marks. (Be sure that you have a device selected
    in the Devices panel—available from Window > Show View > Other > Devices.)

    Using DDMS

    With the DDMS tool, you can simulate location data a few different ways:

    Manually send individual longitude/latitude coordinates to the device.
    Use a GPX file describing a route for playback to the device.
    Use a KML file describing individual place marks for sequenced
    playback to the device.
    For more information on using DDMS to spoof location data, see Using DDMS.

    Using the “geo” command in the emulator console

    To send mock location data from the command line:

    Launch your application in the Android emulator and open a terminal/console
    in your SDK’s /tools directory.
    Connect to the emulator console:
    telnet localhost
    Send the location data:
    geo fix to send a fixed geo-location.
    This command accepts a longitude and latitude in decimal degrees, and
    an optional altitude in meters. For example:
    geo fix -121.45356 46.51119 4392
    geo nmea to send an NMEA 0183 sentence.
    This command accepts a single NMEA sentence of type ‘$GPGGA’ (fix data) or
    ‘$GPRMC’ (transit data). For example:
    geo nmea $GPRMC,081836,A,3751.65,S,14507.36,E,000.0,360.0,130998,011.3,E*62
    For information about how to connect to the emulator console, see Using the
    Emulator Console.

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

Sidebar

Related Questions

if I wanna work/test with my AVD, the Android emulator is super slow, barely
i wanna test a simple brief of using GPS on android. so i write
I wanna test my functionals in my rails application, but the tests require a
I have test.txt file, like this, AA=1 BB=2 CC=3 Now I wanna find BB=
I wanna test my program with VMWare. So I've run the program in a
http://www.guygar.com/test/android/index.html if you click all the things i wanna say it loads some text
I'm new here. I'm developing some Asp.Net applications and i wanna test them on
I wanna build a gallery, but the my problem is how to load the
I wanna run selenium tests from TeamCity using Maven at Linux server without display.
I wanna to detect an input tag that its name is: some[en] in jquery.

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.