Code example for AsyncTask

Methods: execute

0
    /** 
     * This method resolve the city and its timezone and returns the information by 
     * the <code>OnCityAndTimeZoneLocatedCallback</code> callback. 
     */ 
    public void resolve() { 
        mResolveTask.execute();
    } 
 
    public void cancel() { 
        if (mResolveTask.getStatus() == AsyncTask.Status.RUNNING) {
            mResolveTask.cancel(true);
        } 
    } 
 
    private String resolveCity() {
        try { 
            Geocoder geocoder = new Geocoder(mContext, Locale.getDefault());
            List<Address> addresses =
                    geocoder.getFromLocation(mLocation.getLatitude(), mLocation.getLongitude(), 1);
            if (addresses.size() > 0) {
                return addresses.get(0).getLocality();