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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:20:42+00:00 2026-05-30T11:20:42+00:00

i’m using actionbar sherlock/fragments with my app my problem is that i need to

  • 0

i’m using actionbar sherlock/fragments with my app

my problem is that i need to call a async task to run in the fragment which is a static class

the complier is complaining about “No enclosing instance of type KeywordSearch is accessible”

i’ve thought of moving the async class out and create it’s own class, but there are too many variables declared in my KeywordSearch class that is used in the async task

how can i execute the async task without crashing?

my list view class(fragment):

public static class ListFragment extends Fragment {
    private ListView list_list;
    private LazyAdapter adp_list;

    private KeywordSearch.SearchTask run;
    //run.execute();

    //new SearchTask().execute();


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);            
    }
    @Override   
    public void onDestroy()
    {
        if(!RTN_REQ.equals("SSDR") && data_got){
        adp_list.imageLoader.stopThread();
            }
        list_list.setAdapter(null);
        if(data_got)
        ImageLoader.clearCache(true,true);       
        super.onDestroy();      
    }
    @Override
    public void onPause()
    {
        /*
        if(this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT){
            list_list.setNumColumns(2);
        }else if(this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            list_list.setNumColumns(3);
        }
        */
        super.onPause();
    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        View v = inflater.inflate(R.layout.list, container, false);
        adp_list = new LazyAdapter(getActivity(),list_data, 0);
        run = new SearchTask();
        list_list = (ListView) v.findViewById (R.id.list);
        if(list_data != null){

            list_list.setAdapter(adp_list);
            list_list.setOnItemLongClickListener(new OnItemLongClickListener() {
                @Override
                public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {               
                    String[] FINAL = list_data[arg2].split("##");
                    final Intent d = new Intent();
                    d.putExtra("DATA",FINAL[0]);
                    d.setClass(getActivity().getApplicationContext(), Details.class);   
                    startActivity(d);
                    return false;
                    }
            });           
            list_list.setOnItemClickListener(new OnItemClickListener(){
                @Override
                public void onItemClick(AdapterView<?> arg0, View arg1,int arg2, long arg3)
                {
                    if(!eno_act){
                        String[] FINAL = list_data[arg2].split("##");
                        final Intent i = new Intent(Intent.ACTION_VIEW);
                        i.setData(Uri.parse(FINAL[1]));                 
                        startActivity(i);
                    }else{
                        String[] FINAL = list_data[arg2].split("##");
                        level = 1;
                        level_filter = FINAL[2];
                        run.execute();  //this is where it crashes!!




                    }

                }
            });     
        }
        return v;
    }
}

and my SearchTask class:

 class SearchTask extends AsyncTask<Void, Void, String> {

    @Override
    protected void onPreExecute() {
        // TODO Auto-generated method stub
        //....to long to show..
    }

    @Override
    protected String doInBackground(Void... unsued) {
        //....to long to show..
    }

    @Override
    protected void onProgressUpdate(Void... unsued) {
        //....to long to show..
    }

    @Override
    protected void onPostExecute(String sResponse) {
        //....to long to show..
    }
}
  • 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-30T11:20:44+00:00Added an answer on May 30, 2026 at 11:20 am

    Pass those variables of your KeyWordSearch class in constructor of async task class

    for example

    int foo;   
    
    public SearchTask(int foo)  //your variables here
    {
        this.foo = foo;
    }
    

    For passing data example

    //in your async task you can do that in doInBackground or any other method.
    Let foo is your string array

     Bundle b = new Bundle();
     Intent i = new Intent(context, YourActivity.class)
     b.putExtraStringArray("myStringArray", foo);
     i.putExtras(b);
    

    // Receive this array in your activity as

     String[] myArray =  this.getIntent().getStringArrayExtra("myStringArray"); //this should be done after executing asyncTask class.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I would like to run a str_replace or preg_replace which looks for certain words
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.