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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:57:54+00:00 2026-05-23T10:57:54+00:00

Below is my code. I’m getting a NullPointerException while reading the place name from

  • 0

Below is my code. I’m getting a NullPointerException while reading the place name from catching that to a string. Please help me how to solve this.

Exceptiion:

DalvikVM[localhost:8620]    
    Thread [<1> main] (Running) 
    Thread [<8> Binder Thread #2] (Running) 
    Thread [<7> Binder Thread #1] (Running) 
    Daemon Thread [<10> RefQueueWorker@org.apache.http.impl.conn.tsccm.ConnPoolByRoute@405141c8] (Running)  
    Thread [<9> Thread-13] (Suspended (exception NullPointerException)) 
        TravellogActivity$2$1.run() line: 165   

Code:

public boolean onOptionsItemSelected(MenuItem m)
    {

        switch(m.getItemId())
        {
        case R.id.setroute:
            LayoutInflater li= LayoutInflater.from(this);
            View textEntryView = li.inflate(R.layout.alertbox, null);

            final AlertDialog.Builder dialog = new AlertDialog.Builder(this);
            dialog.setTitle("Enter the places");
            dialog.setView(textEntryView);

          splc = (EditText) findViewById(R.id.strtplace);
            dialog.setPositiveButton("Ok", new OnClickListener(){

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub
                    pd = ProgressDialog.show(TravellogActivity.this, "Working..", "Searching your address", true, false);
                    //Show a progress dialog


                    searchAdress = new Thread(){
                    public void run(){
                            String addressInput = splc.getText().toString(); // <-- here Iam getting exception null pointer)
                            try {
                                foundAdresses = gc.getFromLocationName(addressInput, 5); // Search addresses
                                Thread.sleep(1500);
                            } catch (Exception e) {
                                // @todo: Show error message
                            }
                            showAdressResults.sendEmptyMessage(0);                  
                        }
                    };
                    searchAdress.start();

                }
            });
           dialog.show();
        }
        return true;
        }      

 private Handler showAdressResults = new Handler() {
                @Override
                public void handleMessage(Message msg) {
                    pd.dismiss();

                    if (foundAdresses.size() == 0) { // if no address found,
                        // display an error
                        Dialog locationError = new AlertDialog.Builder(
                                TravellogActivity.this).setIcon(0).setTitle(
                                "Error").setPositiveButton(R.string.ok, null)
                                .setMessage(
                                        "Sorry, your address doesn't exist.")
                                .create();
                        locationError.show();

                    } else { // else display address on map
                        for (int i = 0; i < foundAdresses.size(); ++i) {
                            // Save results as Longitude and Latitude
                            // @todo: if more than one result, then show a
                            // select-list
                            Address x = foundAdresses.get(i);
                            latit = x.getLatitude();
                            longi = x.getLongitude();
                        }
                        navigateToLocation((lat * 1000000), (lon * 1000000),myMapView); // display the found address
                    };  

        return  ;

    }

                private void navigateToLocation(double latitude, double longitude,
                        MapView myMapView) {
                    // TODO Auto-generated method stub
                    GeoPoint p = new GeoPoint((int) latitude, (int) longitude); // new
                    MC.animateTo(p);
                    myMapView.displayZoomControls(true); // display Zoom (seems that it doesn't
                    // work yet)
                    MapController mc = myMapView.getController();
                    mc.animateTo(p); // move map to the given point
                    int zoomlevel = myMapView.getMaxZoomLevel(); // detect maximum zoom level
                    mc.setZoom(zoomlevel - 1); // zoom
                    myMapView.setSatellite(false); // display only "normal" mapview
        }
  • 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-23T10:57:54+00:00Added an answer on May 23, 2026 at 10:57 am

    The error maybe in this line:

    splc = (EditText) findViewById(R.id.strtplace);
    

    Replace it with

    splc = (EditText)   textEntryView.findViewById(R.id.strtplace);
    

    because you’re inflating that view, and that EditText view must be in that textEntryView.

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

Sidebar

Related Questions

Below is code used to search a string where Identity= exists and stores that
The below code is from my other questions that I have asked here on
Below code returns ? rather than a random character. Any ideas? Please note that
The below code gives me User-defined conversion must convert to or from enclosing type,
The below code is in PHP echo <input type='submit' name='delete' value='$t2[0]' class='delete_button' onclick='return confirm('Please
The below code is my Method logic . pulic String getData() { if (leg.length
The below code removes certain values from a drop down menu. It works fine
The below code makes application freeze when changing focus from Edit1 to Edit2 after
The below code is working fine. But if i change the html string in
Does anyone know how can I replace this 2 symbol below from the string

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.