0

I want to call a method called getHoroscope() from an AsyncTask, from another class, I'm trying this

String sentence, signo="geminis";
sentence = new ExtendedActivity.Parse().getHoroscope("daily",signo);

But I get error "ExtendedActivity is not an enclosing class". Can you help me?

My ExtendedActivity:

public class ExtendedActivity extends BaseActivity {
(...)
public class Parse extends AsyncTask<String, Void, String> {

        private final ProgressDialog dialog = new ProgressDialog(ExtendedActivity.this);


        @Override
        public String doInBackground(String... params) {

            String option, type, dat, site="", description="", s="";;

            //get the user option
            Bundle extras = getIntent().getExtras();
            option = extras.getString("OPTION");
            type = extras.getString("TYPE");

            description = getHoroscope(type, option);

            return description;
        }


        public String getHoroscope(String type, String option){
            String description="", site;
            (...)
        }
     }
porthfind
  • 1,581
  • 3
  • 17
  • 30

1 Answers1

0

You cand o it:

new ExtendedActivity().new Parse().getHoroscope();

or:

public class ExtendedActivity {
    public static class Parse extends AsyncTask<String, Void, String> {

        @Override
        public String doInBackground(String... params) {

            String description = "";

            description = getHoroscope();

            return description;
        }


        public static String getHoroscope() {
            return null;
        }
    }
}

and call it like that: new ExtendedActivity.Parse().getHoroscope();

E. Fernandes
  • 3,889
  • 4
  • 30
  • 48