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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:06:32+00:00 2026-05-31T18:06:32+00:00

I need to utilize a ActionBar so I need to change the targetSdkVersion to

  • 0

I need to utilize a ActionBar so I need to change the targetSdkVersion to 11.
It is currently targetSdkVersion=”8″. It works fine with targetSdkVersion=”8″ , but when I change it to targetSdkVersion=”11″ it crashes.

The error originates at this line : imageA= new ImageAdapter(this,url);

Error:

  • 03-21 22:09:56.710: E/AndroidRuntime(21824): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ameba.api/com.ameba.api.Home}: android.os.NetworkOnMainThreadException

I’ve tried encapsulating almost every method in an AsyncTask<> , the errors are no longer thrown but the ImageAdapter() (never called) does not work when I do this.

Here is a snippet of the code.

public void onCreate(Bundle bundle) {
    super.onCreate(bundle);      
    setContentView(R.layout.home); 


    title = (TextView)findViewById(R.id.title);
    description = (TextView)findViewById(R.id.description);        
    gridView = (GridView)findViewById(R.id.propGridView);
    thumbNail = (ImageView)findViewById(R.id.propertyThumbnail);
    //thumbNail.setImageBitmap(bm); 
    gridView.setVerticalSpacing(3);
    gridView.setHorizontalSpacing(3);

    //checkHistory();

    ImageDownloader.Mode mode = ImageDownloader.Mode.CORRECT;        

    historyStack.pushValue(url);                                        // Push Value onto history stack
    Log.i("No history:",url+" "+historyStack.getStack().size());        //Debug
    imageA= new  ImageAdapter(this,url);     
    imageA.getImageDownloader().setMode(mode);                          //Set download mode to cache            
    gridView.setAdapter(imageA);                                        //Populate gridView with downloaded bitmap     
}  

public class ImageAdapter extends BaseAdapter  {

//intialize variables
private final ImageDownloader imageDownloader ;
private int SIZE;
private List<Video> myVideos;
private Context mContext; 
private String xmlurl;
private Parser  parser = new Parser();


/*
 * Constructor
 * @params: Context
 * @params: XML url
 */
public ImageAdapter(Context c, String url){
    mContext = c;
    xmlurl = url;
    parser.runParser(xmlurl);    
    imageDownloader = new ImageDownloader();
}

/*
 * (non-Javadoc)
 * @see android.widget.Adapter#getView(int, android.view.View, android.view.ViewGroup)
 */
public View getView(final int position, View convertView, ViewGroup parent) {
    final ImageView view;
    if (convertView == null) {
        view= new ImageView(mContext);
        view.setLayoutParams(new GridView.LayoutParams(175,175));
        view.setPadding(1, 1, 1, 1);

    }
    else{
        view = (ImageView)convertView;
    }
   Log.i("Assingning view","");
   imageDownloader.download(parser.getList().get(position).getThumbNail(),view);    
   return view;
}

/*
 * (non-Javadoc)
 * @see android.widget.Adapter#getCount()
 */
public int getCount() {
    SIZE = parser.getCount();
    return SIZE;
}

/*
 * (non-Javadoc)
 * @see android.widget.Adapter#getItem(int)
 */
public String getItem(int position) {
    return myVideos.get(position).toString();
}

/*
 * (non-Javadoc)
 * @see android.widget.Adapter#getItemId(int)
 */
public long getItemId(int position) {
    return 0;
}

public void setUrl(String url){
    xmlurl = url;
}

/*
 * getMethod
 */
public ImageDownloader getImageDownloader() {
    return imageDownloader;
}



  }
  • 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-31T18:06:33+00:00Added an answer on May 31, 2026 at 6:06 pm

    Take a look at the exception

    Android.os.NetworkOnMainThreadException
    

    It is telling you exactly what is wrong. You are trying to perform network activity (downloading your images) on the main UI thread. In previous versions of Android this was allowed without regard to device performance. Because downloading on the UI thread will severely affect the performance of your application this is discouraged and in later versions of Android will throw the error you see above.

    Move downloading your images into a separate thread and this error will go away.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to render a line break using outputText so that I can utilize
I am working on an app which will be full-screen, but will utilize some
I'm attempting to utilize the socket.h functions within Windows. Essentially, I'm currently looking at
I need to figure out how to utilize one SWF player/file to load different
I need to obtain the error number from an error that has occurred in
I want to utilize introspection capability of python for debugging/development, but cannot find appropriate
For a small project I need to utilize a simple database with very light
Need to pass get parameter without value and without = symbol to utilize external
I am trying to utilize cron in one of my projects where I need
I have built ASP.NET app. I need to utilize a third party COM object

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.