Busy Spinner in Phonegap

  • 2
  • Question
  • Updated 7 years ago
i have noticed that while i could use navigator.notification.activityStart/Stop in PhoneGap 1.4, it is no longer present in 1.5.0.
The above feature was pretty useful to display loading messages almost like the system does. Alternatives provided like JQuery Mobile spinners can be pretty inefficient.
I would like to know of any alternatives for showing a spinner in 1.5. If not supported is it on the roadmap and a suitable alternative for it.

Thanks and Regards
Manoj
Photo of manoj

manoj

  • 1 Post
  • 0 Reply Likes
  • sad

Posted 8 years ago

  • 2
Photo of Shazron

Shazron, Developer Level 42

  • 37 Posts
  • 2 Reply Likes
They were removed ever since 1.0.0rc1 on July 12, 2011. See the Release Notes here and search for 1.0.0rc1: https://github.com/apache/incubator-c...

It was never in 1.4.x. The alternative is to install the removed code as a plugin: https://github.com/phonegap/phonegap-...
Photo of Wytze Schouten

Wytze Schouten

  • 5 Posts
  • 0 Reply Likes
It's not hard to do a javascript workaround that also works for Android (the Phonegap plugin is only for iOS).

Just implement this CSS-based spinner and use a custom function to turn it on and off. You need to adjust the width and height attributes of the spinner to around 15px in order to resemble the phoneGap custom spinner.

One important caveat is to make sure the z-index for the spinner div is the highest around.

I'm using this spinner in two places: on deviceready (if phoneGap works) and on docready after testing that phonegap.available is false. This means the spinner will either pick up as soon as phoneGap's iOS-only custom spinner stops showing, or if phoneGap is not going to do anything, as soon as the document opens.

Try my fiddle post listed on: http://planitize.tumblr.com
Photo of lawgurl

lawgurl

  • 361 Posts
  • 14 Reply Likes
Thank You for link!
Photo of TWilly

TWilly

  • 1 Post
  • 0 Reply Likes
I noticed that the activityStart, activityStop call is inside Notification.java in android. Is this deprecated or just moved inside of a plugin?

Thanks!

From Notificaiton.java...

public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
if (action.equals("beep")) {
this.beep(args.getLong(0));
}
else if (action.equals("alert")) {
this.alert(args.getString(0), args.getString(1), args.getString(2), callbackContext);
return true;
}
else if (action.equals("confirm")) {
this.confirm(args.getString(0), args.getString(1), args.getJSONArray(2), callbackContext);
return true;
}
else if (action.equals("prompt")) {
this.prompt(args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), callbackContext);
return true;
}
else if (action.equals("activityStart")) {
this.activityStart(args.getString(0), args.getString(1));
}
else if (action.equals("activityStop")) {
this.activityStop();
}
else if (action.equals("progressStart")) {
this.progressStart(args.getString(0), args.getString(1));
}
else if (action.equals("progressValue")) {
this.progressValue(args.getInt(0));
}
else if (action.equals("progressStop")) {
this.progressStop();
}
else {
return false;
}