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

  • Home
  • SEARCH
  • 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 8639409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:59:47+00:00 2026-06-12T10:59:47+00:00

In the android app, When I start the activity its showing Black Screen or

  • 0

In the android app, When I start the activity its showing Black Screen or application hang on for few seconds. I want till the Black Screen I want to show the Progress bar. I tried many times but could not do this.

String xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" 
                + "<category><Id>" + catId + "</Id></category>";
StringBuilder resXML = new Connection().getResponseString("http://192.168.1.14/virtualMirror/productlisting.php", xml); // TODO URL change
if(!resXML.equals("")) {
    XMLParser parser = new XMLParser();
    Document doc = parser.getDomElement(resXML.toString()); // getting DOM element
    NodeList nodeList = doc.getElementsByTagName("Product");

    Intent intent = new Intent(this, ProductListing.class);
    Bundle bundle = new Bundle();
    bundle.putLong("CategoryId", catId);
    bundle.putString("CategoryName", catName);
    intent.putExtras(bundle);
    startActivity(intent);
}
  • 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-12T10:59:48+00:00Added an answer on June 12, 2026 at 10:59 am

    Use AsyncTask.

    AsyncTask enables proper and easy use of the UI thread. This class allows to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers.

    The AsyncTask executes everything in doInBackground() inside of another thread, which does not have access to the GUI where your views are.

    preExecute() and postExecute() offer you access to GUI before and after the heavy lifting occurs in this new thread, you can even pass the result of the long operation to postExecute() to then show any results of processing.

    class LoadCategory extends AsyncTask<Void, Void, Void> {
    
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            Pd = new ProgressDialog(getApplicationContext());
            Pd.show();
        }
    
        @Override
        protected Void doInBackground(Void... params) {
            String xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"
                    + "<category><Id>" + catId + "</Id></category>";
    
            StringBuilder resXML = new Connection().getResponseString("http://192.168.1.14/virtualMirror/productlisting.php",xml); // TODO URL change
            if (!resXML.equals("")) {
                XMLParser parser = new XMLParser();
                Document doc = parser.getDomElement(resXML.toString());
                NodeList nodeList = doc.getElementsByTagName("Product");
                return null;
            }
        }
    
        @Override
        protected void onPostExecute(Void result) {
            super.onPostExecute(result);
            Pd.dismiss();
            Intent intent = new Intent(this, ProductListing.class);
            Bundle bundle = new Bundle();
            bundle.putLong("CategoryId", catId);
            bundle.putString("CategoryName", catName);
            intent.putExtras(bundle);
            startActivity(intent);
        }
    }
    

    And Use this class in your onCreate() method.

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        new LoadCategory().execute();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need my Android app to save it's state to disk when its activity
I've to develop an android application and one of its activity is: Detecting New
I start my android app writing with modifying some example codes from the internet.
I'm trying to start a Skype intent from my Android App, passing a phone
In Android Development, I can simply start another Android App with data from my
I have this snippet of shell script: am start -n com.android.gallery3d/com.android.gallery3d.app.MovieActivity -d /sdcard/movie.mp4 sleep
When i try to open a activity in my app which its suposed to
The Activity Lifecycle is giving me headaches. The documentation at http://developer.android.com/reference/android/app/Activity.html is so darn
package com.ebonybutler.cexample3; import android.app.Activity; import android.content.Intent; import android.content.pm.ActivityInfo; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener;
I'm making a function in my android app that, at a home screen the

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.