Page 2 of 2 FirstFirst 12
Results 21 to 24 of 24
  1. #21
    amrmb09 is offline Member
    Join Date
    Nov 2010
    Posts
    75
    Rep Power
    0

    Default Re: Why I'm getting NULL

    i have the following structure..please tell me how to do what have you told me

    Java Code:
    public class CarCurrentPositionActivity extends Activity implements LocationListener
    {..
     ...
    
     LocationListener loclisten = new CarCurrentPositionActivity();
            loclisten.onLocationChanged((Location) loclisten);
    ......
    ......
    ......
    locationManager.requestLocationUpdates(...,...,...., loclisten);
    ...
    ...
    }
    
    public void onLocationChanged(Location loc) // accepts only arguments of type Location
    {
    ...
    ...
    }
    Last edited by Norm; 11-09-2011 at 12:38 AM. Reason: changed quote to code tags

  2. #22
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,327
    Rep Power
    25

    Default Re: Why I'm getting NULL

    You are using the same listener in two places. Its strange that you are passing a reference to the listener to the listener itself:
    loclisten.onLocationChanged((Location) loclisten);
    I have no idea why you would do that. ????
    Why do you cast the listener to a Location? That does not make sense.

    You didn't post the definition for LocationListener. Is the onLocationChanged method in that interface?

    The locationManager object is given a reference to the listener. When the locationManger has a Location event it will call the listener.

  3. #23
    amrmb09 is offline Member
    Join Date
    Nov 2010
    Posts
    75
    Rep Power
    0

    Default Re: Why I'm getting NULL

    Quote Originally Posted by Norm View Post
    Is the onLocationChanged method in that interface?
    Yes .....

    The locationManager object is given a reference to the listener. When the locationManger has a Location event it will call the listener.
    yes ......

  4. #24
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,327
    Rep Power
    25

    Default Re: Why I'm getting NULL

    Its strange that you are passing a reference to the listener to the listener itself:
    loclisten.onLocationChanged((Location) loclisten);
    I have no idea why you would do that. ????
    Why do you cast the listener to a Location? That does not make sense.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 6
    Last Post: 10-18-2010, 10:40 AM
  2. Null :(
    By PhQ in forum Advanced Java
    Replies: 4
    Last Post: 04-12-2010, 01:05 AM
  3. Replies: 2
    Last Post: 03-19-2010, 05:30 PM
  4. Null
    By leapinlizard in forum New To Java
    Replies: 4
    Last Post: 04-29-2009, 11:29 PM
  5. What is NULL
    By bugger in forum New To Java
    Replies: 1
    Last Post: 01-09-2008, 04:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •