Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

no activityIndicator on HTTPClient request

Is it possible to do a HTTPClient without showing the activityIndicator on the top of the screen on the iphone?

I want to do a httprequest which is not visible for the user. Not because it is a secret but because i want to use the activityIndicator for when the user needs to wait for the request, and not when the user can continue using the app with the request on the background.

— asked September 27th 2010 by Peter Griffin
  • activityindicator
  • httpclient
  • no
  • on
  • request
0 Comments

2 Answers

  • Accepted Answer

    Hi Derk,

    1) To hide the activity indicator in the status bar, you could do this:

    Titanium.UI.iPhone.hideStatusBar();
    

    2) To display an activity indicator and prevent the user from clicking on other stuff like the tab bar, you could do something like this:

    function showIndicator()
    {
    
        // window container
        indWin = Titanium.UI.createWindow({
            fullscreen:true
        });
    
        // black view
        var indView = Titanium.UI.createView({
            height:150,
            width:150,
            backgroundColor:'#000',
            borderRadius:10,
            opacity:0.8
        });
    
        indWin.add(indView);
    
        // loading indicator
        actInd = Titanium.UI.createActivityIndicator({
            style:Titanium.UI.iPhone.ActivityIndicatorStyle.BIG,
            height:30,
            width:30
        });
    
        indWin.add(actInd);
    
        // message
        var message = Titanium.UI.createLabel({
            text:'Communicating with' + '\n' + 'the mothership...',
            color:'#fff',
            width:'auto',
            height:'auto',
            textAlign:'center',
            font:{fontFamily:'Helvetica Neue', fontSize:12,fontWeight:'bold'},
            top:270
        });
    
        indWin.add(message);
        indWin.open();
        actInd.show();
    };
    
    function hideIndicator()
    {
        actInd.hide();
        indWin.close({opacity:0,duration:1000});
    };
    

    Regards,

    Simon.

    — answered September 28th 2010 by Simon Kok
    permalink
    0 Comments
  • While I know that is possible from within the iPhone SDK, I haven't seen it within Titanium. It seems like they control that indicator for you.

    Anyways, what you are requesting isn't standard iPhone practice. Typically the network indicator is just supposed to let the user know data is being transferred regardless of whether or not they can continue working. You would display a larger activity indicator and prevent them from doing things for whatever reason the app needs to wait. See the kitchen sink example for activity indicator for some of that implementation.

    — answered September 27th 2010 by Mike Robinson
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.