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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:13:39+00:00 2026-05-27T12:13:39+00:00

i’ve been trying to create a map-related android app, but i realized that the

  • 0

i’ve been trying to create a map-related android app, but i realized that the onLocationChanged of my app had not been called, therefore the map always stay at the default area (US).

my code:

public class MapMainActivity extends MapActivity 
implements OnClickListener, LocationListener {

MapView mapView;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.map_main);

    //reference
    mapView = (MapView)findViewById(R.id.map_view);
    mapView.setBuiltInZoomControls(true);
    this.findViewById(R.id.btn_satellite).setOnClickListener(this);
    this.findViewById(R.id.btn_street).setOnClickListener(this);

}//onCreate

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

    Toast.makeText(this, "GPS tracking started",
        Toast.LENGTH_SHORT).show();

 // Start location updates; 5s/5m
    LocationManager locManager = (LocationManager)getSystemService(
        Context.LOCATION_SERVICE);
    locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
        5000, 0, this);

    Criteria crit = new Criteria();
    crit.setAccuracy(Criteria.ACCURACY_FINE);
    String provider = locManager.getBestProvider(crit, true);
    Location loc = locManager.getLastKnownLocation(provider);

}//onResume

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

    Toast.makeText(this, "GPS tracking stopped", 
        Toast.LENGTH_SHORT).show();

    LocationManager locManager = (LocationManager)getSystemService(
            Context.LOCATION_SERVICE);
        locManager.removeUpdates(this);
}//onPause

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub
    if(v == findViewById(R.id.btn_street))
    {
        mapView.setSatellite(false);
    }//street view

    else if (v == findViewById(R.id.btn_satellite))
    {
        mapView.setSatellite(true);
    }
}//onClick

@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}//isRouteDisplayed

@Override
public void onLocationChanged(Location location) {
    // TODO Auto-generated method stub
    double lat = location.getLatitude();
    double lon = location.getLongitude();

    TextView txtLat = (TextView)findViewById(R.id.txt_lat);
    txtLat.setText(String.format("%.6f", lat));
    TextView txtLon = (TextView)findViewById(R.id.txt_lon);
    txtLon.setText(String.format("%.6f", lon));

    MapView map = (MapView)findViewById(R.id.map_view);
    map.getController().animateTo(new GeoPoint((int)(lat*1E6),//1000000), 
        (int)(lon*1E6)));
}//onLocationChanged

@Override
public void onProviderDisabled(String provider) {
    // TODO Auto-generated method stub
    Toast.makeText(this, "GPS disabled", 
            Toast.LENGTH_SHORT).show();
}//onProviderDisabled

@Override
public void onProviderEnabled(String provider) {
    // TODO Auto-generated method stub
    Toast.makeText(this, "GPS enabled", 
            Toast.LENGTH_SHORT).show();
}//onProviderEnabled

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

}//onStatusChanged


}//class

the whole of my log cat when i run the app through my device (16/12/2011)

D/InputTransport(5357): Input channel constructed: name='40baf680 Toast (client)', ashmemFd=54, receivePipeFd=57, sendPipeFd=58

I/MapActivity(5357): Handling network change notification:CONNECTED

E/MapActivity(5357): Couldn't get connection factory client

I/ViewRoot(5357): !@FINISH DRAWING : sg.edu.tp/sg.edu.tp.SIP_TestMapActivity

I/ViewRoot(5357): !@finishDrawing is completed : sg.edu.tp/sg.edu.tp.SIP_TestMapActivity

I/ViewRoot(5357): !@FINISH DRAWING : Toast

I/ViewRoot(5357): !@finishDrawing is completed : Toast

D/InputTransport(5357): Input channel destroyed: name='40baf680 Toast (client)', ashmemFd=54, receivePipeFd=57, sendPipeFd=58

manifest :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="sg.edu.tp"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="10" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:label="@string/app_name"
            android:name=".SIP_MLT_TestActivity" >
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <uses-library android:name="com.google.android.maps" />
        <activity android:name=".SIP_TestMapActivity"></activity>
        <activity android:name=".SIP_TestDraw1Activity"></activity>
        <activity android:name=".SIP_TestDraw2Activity"></activity>
    </application>

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

</manifest>
  • 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-27T12:13:39+00:00Added an answer on May 27, 2026 at 12:13 pm

    Are you testing that while moving about or while sitting tethered to your dev machine with USB and watching logcat?

    If sitting at dev machine, I suspect you’re not able to move the 5 meters required to trigger a location change event as you requested in your call to requestLocationUpdates

    From API docs: .

    If minDistance is greater than 0, a location will only be broadcast if
    the device moves by minDistance meters.

    try reducing the min distance param in that call to zero and see what happens.

    locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,5000, 0, this);
    

    You probably dont want to leave that at zero for anything other than testing.

    If that doesnt help you might try to see that your GPS is working at all by doing something like this in your onResume, after you ask for locationUpdates:

    Criteria crit = new Criteria();
    crit.setAccuracy(Criteria.ACCURACY_FINE);
    String provider = lm.getBestProvider(crit, true);
    Location loc = lm.getLastKnownLocation(provider);
    

    and see if you are getting good location info.

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

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is

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.