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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:36:51+00:00 2026-06-14T09:36:51+00:00

I’m developing an android app which uses web services developed in .ashx request handler.

  • 0

I’m developing an android app which uses web services developed in .ashx request handler.

  • application waits a lot and shows the black screen while launching the aap for the first time.
  • sometimes it gives error outofMemory VM budget.

Here is some code.

 public class Home extends Activity implements AdapterView.OnItemClickListener {
        /** Called when the activity is first created. */

        Context context = Home.this;
        HashMap<String, String> map = new HashMap<String, String>();
        ArrayList<String> BookTitle = new ArrayList<String>();
        ArrayList<String> BookCoverPhotos = new ArrayList<String>();

        URL bookImageURL = null;
        Bitmap bitMapImage = null;

        View homeTabLayout;
        View reviewLayout;
        ArrayList<String> ImageUrl = new ArrayList<String>();
        ImageButton btnBack;


        // XML Parsing
        ArrayList<HashMap<String, String>> menuItems = new ArrayList<HashMap<String, String>>();

        // All static variables
        static final String URL = "http://www.my_url_goes_here.com/rxxxxxxxandler.ashx";
        // XML node keys
        static final String KEY_ITEM = "Book"; // parent node
        static final String KEY_ID = "BookID";
        static final String KEY_BOOKTITLE = "BookTitle";
        static final String KEY_BOOKCODE = "BookCode";
        static final String KEY_BOOKIMAGE = "BookImage";

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.home_activity);
            // Get XML Data in a Array List

            XMLParser parser = new XMLParser();
            String xml = parser.getXmlFromUrl(URL, "Imam Ali"); // getting XML
            Document doc = parser.getDomElement(xml); // getting DOM element

            NodeList nl = doc.getElementsByTagName(KEY_ITEM);

            // looping through all item nodes <item>
            for (int i = 0; i < nl.getLength(); i++) {
                // creating new HashMap
                Node node = nl.item(i);
                Element e = (Element) nl.item(i);
                // adding each child node to HashMap key => value
                map.put(KEY_ID, parser.getValue(e, KEY_ID));
                BookTitle.add(parser.getValue(e, KEY_BOOKTITLE));
                BookCoverPhotos.add("http://shiaislamicbooks.com/books_Snaps/"+parser.getValue(e, KEY_BOOKCODE)+"/1.jpg");
                Log.i("URLs", BookCoverPhotos.toString());
                // String
                // imgUrl="http://shiaislamicbooks.com/books_Snaps/"+parser.getValue(e,
                // KEY_BOOKCODE);
                map.put(KEY_BOOKTITLE, parser.getValue(e, KEY_BOOKTITLE));
                map.put(KEY_BOOKCODE, parser.getValue(e, KEY_BOOKCODE));
                map.put(KEY_BOOKIMAGE, parser.getValue(e, KEY_BOOKIMAGE));

                // adding HashList to ArrayList
                menuItems.add(map);

                Log.i("Array List", menuItems.toString());
            }

            homeTabLayout = findViewById(R.id.rel_HomeLayout);
            reviewLayout = findViewById(R.id.scroll_ReviewLayout);
            reviewLayout.setVisibility(View.GONE);

            btnBack = (ImageButton) findViewById(R.id.btnBack);
            btnBack.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    reviewLayout.setVisibility(View.GONE);
                    homeTabLayout.setVisibility(View.VISIBLE);

                }
            });

            final GridView gridView = (GridView) findViewById(R.id.gridview);
            gridView.setAdapter(new ImageAdapter(this));
            gridView.setOnItemClickListener(new OnItemClickListener() {

                @Override
                public void onItemClick(AdapterView<?> arg0, View arg1, int pos,
                        long arg3) {


                }
            });

       }
        public class ImageAdapter extends BaseAdapter {
            private Context context;
            public ImageAdapter(Context c) {
                context = c;
            }

            // ---returns the number of images---
            public int getCount() {

                return BookCoverPhotos.size();
            }

            // ---returns the ID of an item---
            public Object getItem(int position) {
                return position;
            }

            public long getItemId(int position) {
                return position;
            }
            // ---returns an ImageView view---
            public View getView(int position, View convertView, ViewGroup parent) {
                // ImageView bmImage;
                ImageView img_BookCoverPhoto;
                img_BookCoverPhoto = new ImageView(context);
                LayoutInflater inflater = (LayoutInflater) context
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                View row = inflater.inflate(R.layout.grid_style, parent, false);
                TextView txt_BooksTitle = (TextView) row
                        .findViewById(R.id.txt_BookTitle);
                txt_BooksTitle.setText(BookTitle.get(position) + "");
                img_BookCoverPhoto = (ImageView) row
                        .findViewById(R.id.imgBookCover);
                try {
                    bookImageURL = new URL(
                            BookCoverPhotos.get(position));
                } catch (MalformedURLException e) {
                    e.printStackTrace();
                    Toast.makeText(context, "Network Error", Toast.LENGTH_LONG).show();
                    Log.i("URL", "ERROR");
                }

                try {
                    bitMapImage = BitmapFactory.decodeStream(bookImageURL
                            .openConnection().getInputStream());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    Toast.makeText(context, "Bitmap Error", Toast.LENGTH_LONG).show();
                    Log.i("BITMAP", "ERROR");
                }

                img_BookCoverPhoto.setImageBitmap(bitMapImage);

                return row;
            }
        }

    }

One more thing to tell you all that I’m using the XML parsing using the this tutorial.

  • Is there any excessive unwanted code here in my app.
  • Is there any way to load the first some basic UI and then app should start downloading the data (i.e images in bitmaps and text data) from the web server.
  • And suggest me should i use AsyncTask, please provide some links for basic tutorials about AsyncTask.

Please provide code with some description.

  • 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-06-14T09:36:52+00:00Added an answer on June 14, 2026 at 9:36 am

    Use Asynctask to perform network operations like fetching data from server. All the network hand shake can be done in doInBackground() of AsyncTask class. UI updations can be performed in onPostExecute()

    Example

    Study

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. 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.