How to access a External class member inside a android Service?
<p>Basically I have a android Service <em>LogService</em> which I trigger from my MainActivity. Inside service class I am creating a object of LocationListener class <em>LocationFetcher</em> with the name locationFetcher. The <em>LocationFetcher</em> class has a public string member <em>FormattedResult</em>. Now Inside the LogService.run() I want to fetch FormattedResult periodically. How to do That ?? Below is code for reference.</p>

<p>I have a LocationListener like This:</p>

<pre><code>/*This is relevant content of LocationFetcher.java */

public class LocationFetcher extends TimerTask implements LocationListener{

    public String FormattedResult;
    private boolean availableFlag;
    @Override
    public void onLocationChanged(Location arg0) {
        // TODO Auto-generated method stub
        this.availableFlag=true;
        this.FormattedResult=String.format(Locale.ENGLISH, "Lat=\t%f\nLong=\t%f", arg0.getLatitude(),arg0.getLongitude());
        Log.d("LocationFetcher",this.FormattedResult);
    }
    @Override
    public void run() {
        // TODO Auto-generated method stub
        Log.d("LocationFetcher","This is Timer Run !!!");
    }}
</code></pre>

<p>My android service is like this :</p>

<pre><code>/* This is the relevant pert from LogService.java file*/

public class LogService extends Service{
    private Logger logger;
    private LocationFetcher locationFetcher;
    public LocationManager locationManager;
    private Timer timer1;

    @Override
    public int onStartCommand(Intent intent,int flags, int startId){
    super.onStartCommand(intent, flags, startId);
    if(!this.running){

        this.logger = new Logger();  //Initiated member from subclass
        this.logger.start();         //Started
        this.timer1 = new Timer();   //Timer for timed job          
        this.locationFetcher = new LocationFetcher();//THIS IS MY EXTERNAL CLASS in "LocationFetcher.java"  
                                      //I am using GPS data.
        this.locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
        if(this.locationFetcher != null){//NULLPointerException is thrown if I REMOVE this if ??WHY
            this.locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this.locationFetcher);
            this.timer1.scheduleAtFixedRate(this.locationFetcher, 5000, 2000); 
         //Below Line still throws NullPointrException ??WHY
         //this.locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this.locationFetcher);

        }else{
            Log.d("GPS-Logger"," Found Null LocationFlecther !");
        }
    }
    public void run(){
        LogService ll = LogService.this;
        LocationManager mgr = ll.locationManager; //THIS IS MY QUESTION
        // HOW DO I ACCESS THE GPS LOCATION STORED in locationmanager.FormattedResult
        // Which is a string
        // //////////////////////////////////////////////////////////////////////////
        while(ll.isActive){

            try {

                String temp ;
                if(!temp.isEmpty()){
                    Log.d("GPS-Logger","data is :"+temp);
                }
                Log.d("GPS-Logger","data is :");
                Thread.sleep(5000);
                sec +=1 ;
                if(sec &gt;= 12){
                    Log.d("GPS-Logger","Sending Data Here");
                    sec = 0;
                }

            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                ll.isActive=false;
                Log.d("GPS-Logged","EXIT Request Received");
            }
        }
    }
</code></pre>

<p>I know that I have asked multiple Questions above but I didn't knew how to separate them.
NEED HELP!!!</p>
