NullPointerException from the geocoder class while retriving the place name from edit text to string
<p>Below is my code. I'm getting a <code>NullPointerException</code> while reading the place name from catching that to a string. Please help me how to solve this.</p>

<p>Exceptiion:</p>

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

<p>Code:</p>

<pre><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(); // &lt;-- 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 &lt; 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
        }
</code></pre>
