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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:56:30+00:00 2026-06-04T20:56:30+00:00

I tried to get lat and long position by passing values from Telnet. After

  • 0

I tried to get lat and long position by passing values from Telnet. After i complete that now i try to implement Reverse Geocoding to Get apporx address of place in emulator.
Followd this link

but it shows application flows stopped unexpectedly.

Error in log cat..

05-19 16:51:14.292: E/AndroidRuntime(460): java.lang.NullPointerException
05-19 16:51:14.292: E/AndroidRuntime(460):  at com.gps.HelloAndroidGpsActivity$ReverseGeocodeLookupTask.onPostExecute(HelloAndroidGpsActivity.java:137)
05-19 16:51:14.292: E/AndroidRuntime(460):  at com.gps.HelloAndroidGpsActivity$ReverseGeocodeLookupTask.onPostExecute(HelloAndroidGpsActivity.java:1)
05-19 16:51:14.292: E/AndroidRuntime(460):  at android.os.AsyncTask.finish(AsyncTask.java:417)
05-19 16:51:14.292: E/AndroidRuntime(460):  at android.os.AsyncTask.access$300(AsyncTask.java:127)
05-19 16:51:14.292: E/AndroidRuntime(460):  at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
05-19 16:51:14.292: E/AndroidRuntime(460):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-19 16:51:14.292: E/AndroidRuntime(460):  at android.os.Looper.loop(Looper.java:130)
05-19 16:51:14.292: E/AndroidRuntime(460):  at android.app.ActivityThread.main(ActivityThread.java:3683)
05-19 16:51:14.292: E/AndroidRuntime(460):  at java.lang.reflect.Method.invokeNative(Native Method)
05-19 16:51:14.292: E/AndroidRuntime(460):  at java.lang.reflect.Method.invoke(Method.java:507)
05-19 16:51:14.292: E/AndroidRuntime(460):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-19 16:51:14.292: E/AndroidRuntime(460):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-19 16:51:14.292: E/AndroidRuntime(460):  at dalvik.system.NativeStart.main(Native Method)

…

HelloAndroidGpsActivity.java

package com.gps;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;

import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
import com.gps.GeoCodeResult;
import com.gps.GeoCoder;



public class HelloAndroidGpsActivity extends Activity {

    private static final long MINIMUM_DISTANCE_CHANGE_FOR_UPDATES = 1; // in Meters
    private static final long MINIMUM_TIME_BETWEEN_UPDATES = 1000; // in Milliseconds

    private GeoCoder geoCoder = new GeoCoder();

    protected LocationManager locationManager;
    protected Location currentLocation;

    protected Button retrieveLocationButton;
    protected Button reverseGeocodingButton;

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        retrieveLocationButton = (Button) findViewById(R.id.retrieve_location_button);
        reverseGeocodingButton = (Button) findViewById(R.id.reverse_geocoding_button);

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

        locationManager.requestLocationUpdates(
                LocationManager.GPS_PROVIDER, 
                MINIMUM_TIME_BETWEEN_UPDATES, 
                MINIMUM_DISTANCE_CHANGE_FOR_UPDATES,
                new MyLocationListener()
        );

        retrieveLocationButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                showCurrentLocation();
            }
        });

        reverseGeocodingButton.setOnClickListener(new OnClickListener() {            
            public void onClick(View v) {                
                performReverseGeocodingInBackground();
            }
        });

    }    

    protected void performReverseGeocodingInBackground() {
        showCurrentLocation();
        new ReverseGeocodeLookupTask().execute((Void[])null);
    }

    protected void showCurrentLocation() {

        currentLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

        if (currentLocation != null) {
            String message = String.format(
                    "Current Location \n Longitude: %1$s \n Latitude: %2$s",
                    currentLocation.getLongitude(), currentLocation.getLatitude()
            );
            Toast.makeText(HelloAndroidGpsActivity.this, message,
                    Toast.LENGTH_LONG).show();
        }

    }   

    private class MyLocationListener implements LocationListener {

        public void onLocationChanged(Location location) {
            String message = String.format(
                    "New Location \n Longitude: %1$s \n Latitude: %2$s",
                    location.getLongitude(), location.getLatitude()
            );
            Toast.makeText(HelloAndroidGpsActivity.this, message, Toast.LENGTH_LONG).show();
        }

        public void onStatusChanged(String s, int i, Bundle b) {
            Toast.makeText(HelloAndroidGpsActivity.this, "Provider status changed",
                    Toast.LENGTH_LONG).show();
        }

        public void onProviderDisabled(String s) {
            Toast.makeText(HelloAndroidGpsActivity.this,
                    "Provider disabled by the user. GPS turned off",
                    Toast.LENGTH_LONG).show();
        }

        public void onProviderEnabled(String s) {
            Toast.makeText(HelloAndroidGpsActivity.this,
                    "Provider enabled by the user. GPS turned on",
                    Toast.LENGTH_LONG).show();
        }

    }

    public class ReverseGeocodeLookupTask extends AsyncTask <Void, Void, GeoCodeResult> {

        private ProgressDialog progressDialog;

        @Override
        protected void onPreExecute() {
            this.progressDialog = ProgressDialog.show(
                    HelloAndroidGpsActivity.this,
                    "Please wait...contacting Yahoo!", // title
                    "Requesting reverse geocode lookup", // message
                    true // indeterminate
            );
        }

        @Override
        protected GeoCodeResult doInBackground(Void... params) {
            return geoCoder.reverseGeoCode(currentLocation.getLatitude(), currentLocation.getLongitude());
        }

        @Override
        protected void onPostExecute(GeoCodeResult result) {

            Toast.makeText(HelloAndroidGpsActivity.this, result.toString(), Toast.LENGTH_LONG).show();            
        }

    }

}

GeoCoder.java

*package com.gps;
import com.gps.GeoCodeResult;
import com.gps.HttpRetriever;
import com.gps.XmlParser;
public class GeoCoder {

    private static final String YAHOO_API_BASE_URL = "http://where.yahooapis.com/geocode?q=%1$s,+%2$s&gflags=R&appid=[yourappidhere]"; **//This is correct API**
       private HttpRetriever httpRetriever = new HttpRetriever();
        private XmlParser xmlParser = new XmlParser();

        public GeoCodeResult reverseGeoCode(double latitude, double longitude) {

            String url = String.format(YAHOO_API_BASE_URL, String.valueOf(latitude), String.valueOf(longitude));        
            String response = httpRetriever.retrieve(url);
            return xmlParser.parseXmlResponse(response);

        }
    }*

GeoCodeResult

package com.gps;
public class GeoCodeResult {

    public String line1;
    public String line2;
    public String line3;
    public String line4;

    @Override
    public String toString() {

        StringBuilder builder = new StringBuilder();
        builder.append("Location:");

        if (line1!=null)
            builder.append("-"+line1);
        if (line2!=null)
            builder.append("-"+line2);
        if (line3!=null)
            builder.append("-"+line3);
        if (line4!=null)
            builder.append("-"+line4);

        return builder.toString();

    }

}

Problem is geocode result is null

Did i missed something . Point me were i did mistake. Thank you

  • 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-04T20:56:31+00:00Added an answer on June 4, 2026 at 8:56 pm

    Sometimes it happens.It gives us null.Same problem was in my case.
    Try it on other devices or after some time.Try to hit server for address only once in a minute.
    More than one request in one minute for address,can cause ‘null’

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

Sidebar

Related Questions

I am trying to get an address based on the long/lat. it appears that
I'm trying to retrieve listings that are near a user's current lat/long position. Have
I have a string like this: {\lat\:37.790388261934424,\lng\:-122.46047996826172},{\lat\:37.789608231530124,\lng\:-122.46344112701416} And when I tried to get rid
I'm trying serverside reverse geocoding that can get me a json response and now
I am trying to use these two lines to get lat/long info when given
I am trying to use a PHP script to get the Lat/Long of an
I tried to get avatar at single (post) page by these codes <?php echo
I tried to get my application run at a specified time but I can't
When i tried to get the current location of a user via FQL, Graph
Firstly I tried to get fabric working, but it kept asking me for a

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.