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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:40:27+00:00 2026-06-04T17:40:27+00:00

I’m having some troubles trying to display the main Activity in Android. The problems

  • 0

I’m having some troubles trying to display the main Activity in Android. The problems started when the Activity extends MapView (I don’t know why). The LogCat shows some errors but I dont know what they mean. Here is the LogCat:

03-07 05:42:56.859: D/AndroidRuntime(15357): Shutting down VM
03-07 05:42:56.859: W/dalvikvm(15357): threadid=1: thread exiting with uncaught exception (group=0x40018578)
03-07 05:42:56.859: E/AndroidRuntime(15357): FATAL EXCEPTION: main
03-07 05:42:56.859: E/AndroidRuntime(15357): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.geo.location/com.geo.location.GeoLocationActivity}: java.lang.IllegalArgumentException: listener==null
03-07 05:42:56.859: E/AndroidRuntime(15357):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
03-07 05:42:56.859: E/AndroidRuntime(15357):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
03-07 05:42:56.859: E/AndroidRuntime(15357):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-07 05:42:56.859: E/AndroidRuntime(15357):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
03-07 05:42:56.859: E/AndroidRuntime(15357):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-07 05:42:56.859: E/AndroidRuntime(15357):    at android.os.Looper.loop(Looper.java:130)
03-07 05:42:56.859: E/AndroidRuntime(15357):    at android.app.ActivityThread.main(ActivityThread.java:3687)
03-07 05:42:56.859: E/AndroidRuntime(15357):    at java.lang.reflect.Method.invokeNative(Native Method)
03-07 05:42:56.859: E/AndroidRuntime(15357):    at java.lang.reflect.Method.invoke(Method.java:507)
03-07 05:42:56.859: E/AndroidRuntime(15357):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
03-07 05:42:56.859: E/AndroidRuntime(15357):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
03-07 05:42:56.859: E/AndroidRuntime(15357):    at dalvik.system.NativeStart.main(Native Method)
03-07 05:42:56.859: E/AndroidRuntime(15357): Caused by: java.lang.IllegalArgumentException: listener==null
03-07 05:42:56.859: E/AndroidRuntime(15357):    at android.location.LocationManager.requestLocationUpdates(LocationManager.java:444)
03-07 05:42:56.859: E/AndroidRuntime(15357):    at com.geo.location.GeoLocationActivity.onCreate(GeoLocationActivity.java:64)
03-07 05:42:56.859: E/AndroidRuntime(15357):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-07 05:42:56.859: E/AndroidRuntime(15357):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
03-07 05:42:56.859: E/AndroidRuntime(15357):    ... 11 more

And this is the code of the app.

public class GeoLocationActivity extends MapActivity implements LocationListener {
    private TextView lblLatitud; 
    private TextView lblLongitud;
    private TextView lblPrecision;
    private TextView lblEstado;
    private TextView lblVelocidad;
    private DecimalFormat df;
    private MapView lblMapView; 
    private MapController mapController; 
    private LocationManager locManager;
    private LocationListener locListener;

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

        df = new DecimalFormat("#.########");
        lblLatitud = (TextView) findViewById(R.id.LblPosLatitud);
        lblLongitud = (TextView) findViewById(R.id.LblPosLongitud);
        lblPrecision = (TextView) findViewById(R.id.LblPosPrecision);
        lblVelocidad = (TextView) findViewById(R.id.LblV);
        lblEstado = (TextView) findViewById(R.id.textView8);
        lblPrecision = (TextView) findViewById(R.id.LblPosPrecision);
        lblMapView  = (MapView) findViewById(R.id.mapview);
        lblMapView.setBuiltInZoomControls(true);

        lblLatitud.setText("");
        lblLongitud.setText("");
        lblPrecision.setText("");
        lblVelocidad.setText("");
        lblEstado.setText("");
        lblPrecision.setText("");

        locManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
        //Obtenemos la última posición conocida
        Location loc = locManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
        //Mostramos la última posición conocida
        mostrarPosicion(loc);
        locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locListener);

    }

    //Rellena los TextView de la Activity con la información básica de la posición
    private void mostrarPosicion(Location loc) {
        if(loc != null){
            lblLatitud.setText(String.valueOf(df.format(loc.getLatitude())));
            lblLongitud.setText(String.valueOf(df.format(loc.getLongitude())));
            lblPrecision.setText(String.valueOf(loc.getAccuracy())+ " metros");
            lblEstado.setText("GPS Ok");
            lblVelocidad.setText(String.valueOf(loc.getSpeed()*(3600/1000)) + "km/h <=> " + String.valueOf(loc.getSpeed()) + "m/s"); 
        }else{
            lblLatitud.setText("(sin_datos)");
            lblLongitud.setText("(sin_datos)");
            lblEstado.setText("(GPS no disponible)");
            lblPrecision.setText("(sin_datos)");
            lblVelocidad.setText("(sin_datos)");
        }
    }

    @Override
    protected boolean isRouteDisplayed() {
        return false;
    }

    //Añade un punto al array y muestra la posicion en el mapa
    protected void updateLocation(Location location) {
        GeoPoint point = new GeoPoint((int)(location.getLatitude() * 1E6), (int)(location.getLongitude() * 1E6));   
        mapController = lblMapView.getController();
        mapController.animateTo(point);
        mapController.setZoom(lblMapView.getMaxZoomLevel());    
        List<Overlay> mapOverlays = lblMapView.getOverlays();
        MiOverlay2 marker = new MiOverlay2(point, this);
        mapOverlays.add(marker);
        lblMapView.invalidate();
    }

    public void onLocationChanged(Location location) {
        lblEstado.setText("Gps Ok");
        mostrarPosicion(location);
        updateLocation(location);
    }
    public void onProviderDisabled(String provider){
        lblEstado.setText("No connection");
        Intent intent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
        startActivity(intent);
    }
    public void onProviderEnabled(String provider){
        lblEstado.setText("Gps Ok");
    }
    public void onStatusChanged(String provider, int status, Bundle extras){
        Log.i("", "Provider Status: " + status);
    }
}


 /***********************************************************************
 * CLASS:                                                               *
 * OVERLAY QUE PINTA LAS FLECHAS EN LUGAR DONDE ESTA SITUADO EL USUARIO *
 ***********************************************************************/
class MiOverlay extends Overlay { 
    GeoPoint punto; 
    Context ctxt; 

    public MiOverlay (GeoPoint punto, Context ctxt) {
        super();
        this.punto = punto;
        this.ctxt = ctxt; 
    }

    @Override
    public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
        super.draw(canvas, mapView, shadow);

       //se traduce el punto geo localizado a un punto en la pantalla
       Point scrnPoint = new Point();
       mapView.getProjection().toPixels(punto, scrnPoint);

       //se construye un bitmap a partir de la imagen
       Bitmap marker = BitmapFactory.decodeResource(ctxt.getResources() , R.drawable.arrow);

       //se dibuja la imagen del marker
       canvas.drawBitmap(marker,
               scrnPoint.x - marker.getWidth() / 2,
               scrnPoint.y - marker.getHeight(), 
               null);
       return true;
    }
} 

As you can see, it’s a very simple program, but I can’t find out the problem.

  • 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-04T17:40:28+00:00Added an answer on June 4, 2026 at 5:40 pm

    The LocationListener, locListener, is never initialized, and is therefore null…

    locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locListener);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

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.