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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:32:53+00:00 2026-05-25T15:32:53+00:00

I am trying to download xml files from server when my application starts. So

  • 0

I am trying to download xml files from server when my application starts. So i want to show splash screen until am done with downloading and then show next screen. below is my code:

Here, i want to show My splash screen when getTopNotDoc() method is under execution. and after completion of that method show next screen.

//get _topics and notification document<br>
_getDoc = new ServerConnectivity(this);

public class ServerConnectivity {

private Document _questionDoc;
private Document _topics;
private Document _notifications;

public ServerConnectivity(ApplicationSession appSession){
    //getTopNotDoc();
    _this = this;
    _appSession = appSession;
            new Thread(new Runnable(){
               public void run(){   
           getTopNotDoc();
               }
            }).start();
    }
}


private void getTopNotDoc(){
    InputStream inputStream = null ;
    try{
        // Build a document based on the XML file.
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();

        inputStream = getClass().getResourceAsStream("topics.xml");
        _topics = builder.parse( inputStream );
        inputStream = getClass().getResourceAsStream("notification.xml");
        _notifications = builder.parse( inputStream ); 

        if(_topics == null || _notifications == null){
                Dialog.alert("Unable to connect to internet");
        }
    } 
    catch ( Exception e ){
        System.out.println( e.toString() );
    }
    finally{
        if(inputStream != null){
            try {
                inputStream.close();
            } 
            catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
  • 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-25T15:32:54+00:00Added an answer on May 25, 2026 at 3:32 pm

    To add some flexibility and keep your classes loosely coupled together, you could make some modifications to your ServerConnectivity class so your calls could go something like the following:

    // push your splash screen on to the stack
    //
    final SplashScreen splashScreen = new SplashScreen();
    UiApplication.getUiApplication().pushScreen(splashScreen);
    
    _getDoc = new ServerConnectivity(this, new ServerConnectivityListener() {
        public void onCompleted(ServerConnectivity sender) {
    
            // display next screen
            //
            UiApplication.getUiApplication().invokeLater(new Runnable() {
                public void run() {
                    splashScreen.close();
                    UiApplication.getUiApplication().pushScreen(new NextScreen());
                }
            });
        }
    
        public void onError(ServerConnectivity sender) {
            splashScreen.close();
            // display error message, retry, etc...
        }
     });
    

    For this to work, you need an interface with the following definition:

    public interface ServerConnectivityListener {
        void onCompleted(ServerConnectivity sender);
        void onError(ServerConnectivity sender);
    }
    

    So, your ServerConnectivity class maintains a reference to some object that implements the interface called ServerConnectivityListener This allows you to maintain loose coupling between the subject class and any observers that need to listen for events.

    Within ServerConnectivity, you would make calls to the listener’s methods something like this:

    // begin excerpt from above...
    //
    if(_topics == null || _notifications == null) {
         _listener.onError(this);
    } else {
        _listener.onCompleted(this);
    }
    catch ( Exception e ){
        System.out.println( e.toString() );
        _listener.onError(this);
    //
    // end excerpt from above...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to download files in subdirectories from an ftp server with ant. The
I am trying to download an XML file(in my J2ME Application) from a location
I'm trying to download images (.jpg) from web folder using wget. I want to
What I'm trying to do is this: I want my application to download an
I am trying to download multiple images from a URL stored in an XML
Im trying to download share data from a stock exchange using python. The problem
I'm trying to download images from URLs and pass them to PIL. I would
I am trying to download the image from the url http://a3.twimg.com/profile_images/414797877/05052008321_bigger.jpg I am using
I'm trying to download a file from my provider. The url is protected with
So far i wrote a code to download a file from ftp server then

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.