native.setActivityIndicator

This is a continuation of the discussion from the API page.
http://developer.anscamobile.com/reference/index/nativesetactivityindicator
[import]uid: 7559 topic_id: 24297 reply_id: 324297[/import]

Is there a way to set a message with native.setActivityIndicator?? ie. “Loading” or “Please wait” [import]uid: 71201 topic_id: 24297 reply_id: 101627[/import]

There is no message associated with the setActivityIndicator. You could display your text message on the screen (using display.newText) before calling setActivityIndicator and it would display in the background. You would then remove the text when you canceled the indicator. [import]uid: 7559 topic_id: 24297 reply_id: 101632[/import]

Help! I CANNOT FIGURE THIS OUT!

How do get the activity indicator to show when doing something?

A “tap” fires my “do a complex operation” functions. I cannot get the indicator to show, no matter where I put it INSIDE the functions that are fired by the “tap”.

Please don’t tell me again that stupid “native.setActivityIndicator” method! Of course, I don’t want to wait a fixed time. Besides, I can’t even get the damned thing to show AT THE BEGINNING of the delayed process.

HELP! Just give me an example of firing the indicator from a function called by a tap! [import]uid: 37366 topic_id: 24297 reply_id: 112553[/import]

native.setActivityIndicator( true ) to turn on…
native.setActivityIndicator( false ) to turn off.

http://docs.coronalabs.com/api/library/native/setActivityIndicator.html
[import]uid: 71201 topic_id: 24297 reply_id: 112555[/import]

Yeah. I know. However, because this doesn’t work inside of active blocks, that’s useless advice, folks.

First, the simulator doesn’t simulate this properly. I know because I think I got something working, but it doesn’t work in simulator.

Second, it seems I have to fire the main chunk of code using the time-delay technique, inside my main code. This scares me… I don’t want activity until AFTER the main code has finished. [import]uid: 37366 topic_id: 24297 reply_id: 112556[/import]

You really need to post a code example of what you are trying to do. Trying to describe it and say it doesn’t work won’t get much help.

There are no outstanding bugs associated with the activity indicator so I suspect the issue is how you are using it. [import]uid: 7559 topic_id: 24297 reply_id: 112559[/import]

All my whining — deserved, since I’ve put a lot of time into this, but not justified, since I finally figured it out.

It requires one to stop thinking in terms of linear programming, which simply isn’t trivial. Sigh.

I DO have to handle the complex procedures using the time-delay technique.

The simulator doesn’t show the activity indicator perfectly — the screen dims, a flicker of the spinner graphic — but good enough.

I can’t post the code — it’s under contract, and about 5,000 lines altogether.

I think I’ve got the hang of it now, this non-linear programming. [import]uid: 37366 topic_id: 24297 reply_id: 112565[/import]

I’m not sure how to go about calling the activity indicator when using some code to upload content to Facebook. My app uploads an image which may take a few seconds. I set the activityIndicator, but I can’t seem to get it to cancel on Android (on iPad it works fine).

function fbListener(event)  
 native.setActivityIndicator(true)  
 if event.isError then  
 native.showAlert("ERROR", event.response, { "OK" } )  
 native.setActivityIndicator(false)  
 else  
 if event.type == "session" and event.phase == "login" then  
 onLoginSuccess()  
 elseif event.type == "request" then  
 native.setActivityIndicator(false)  
 native.showAlert("Success", "The photo has been uploaded.",{"OK"})  
 storyboard.gotoScene("mixedUp","fade",400)  
 end  
 end  
end  

I tried to remove the calls and use my own function (setting true/false) but that still didn’t work:

function setActivityIndicator(value)  
 if(value==nil) then  
 value = false  
 timer.performWithDelay(50, function()   
 native.setActivityIndicator(value)  
 end  
 )  
end  

With this Facebook listener - how would I go about setting and cancelling the activity indicator.

Thanks [import]uid: 140429 topic_id: 24297 reply_id: 113514[/import]

Just to answer my own quest and to help anyone else stuck - the setActivityIndicator must be set true and then leter, false - from 2 separate function calls (should I say 2 separate threads?) This is best done with a callback method. [import]uid: 140429 topic_id: 24297 reply_id: 114421[/import]