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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:55:38+00:00 2026-05-26T21:55:38+00:00

Scenario I have made a phonegap 1.0.0 app which loads the current location via

  • 0

Scenario

I have made a phonegap 1.0.0 app which loads the current location via Google Map. I have also created a plugin to display the activity indicator on the top of the screen, i.e. on the status bar of the iPhone.

function onBodyLoad()
{   
    document.addEventListener("deviceready",onDeviceReady,false);
};

function onDeviceReady()
{
    //Get the plugin object
    var ai = window.plugins.ActivityIndicator;
    //Stop the spin, if any activity was going on earlier
    ai.end();
    if(navigator.geolocation) {
        //Start spinning, indicating that some network activity is going on
        ai.set();
        navigator.geolocation.getCurrentPosition(initSearch);
    }
    else alert("Please try reloading");
    //Stop spinning after 10 seconds
    window.setTimeout(ai.end, 10000);
};

The Javascript code for the plugin is as follows:

var ActivityIndicator = function() {};
ActivityIndicator.prototype.set = function() 
{
    PhoneGap.exec("ActivityIndicator.start");
};
ActivityIndicator.prototype.end = function() 
{
    PhoneGap.exec("ActivityIndicator.end");
};
ActivityIndicator.install = function() {
    if(!window.plugins)
        window.plugins = {};
    window.plugins.ActivityIndicator = new ActivityIndicator();
    return window.plugins.ActivityIndicator;
};
PhoneGap.addConstructor(ActivityIndicator.install);

The Objective-C code for the plugin is as follows:

#import <Foundation/Foundation.h>

#ifdef PHONEGAP_FRAMEWORK
#import <PhoneGap/PGPlugin.h>
#else
#import "PGPlugin.h"
#endif

@interface ActivityIndicator : PGPlugin {}
-(void) start:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-(void) end:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
@end

@implementation ActivityIndicator

- (void)start:(NSMutableArray *)arguments withDict:(NSMutableDictionary *)options
{
    UIApplication* app = [UIApplication sharedApplication];
    app.networkActivityIndicatorVisible = YES;
}

- (void)end:(NSMutableArray *)arguments withDict:(NSMutableDictionary *)options
{
    UIApplication* app = [UIApplication sharedApplication];
    app.networkActivityIndicatorVisible = NO;
}

@end

Problem

As you can see in the code snippet above, I have set the Timeout for the spinning to stop after 10 seconds.

Question

How to make the activityIndicator start/stop whenever there is any network Activity?

  • 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-26T21:55:38+00:00Added an answer on May 26, 2026 at 9:55 pm

    You could’ve use notificationEx instead of doing your own, but it’s good for knowledge 🙂

    Anyways, is the map calls ajax-based? If yes, and you are using jQuery, assign .ajaxStart() and .ajaxStop() functs.

    I do the following:

    function onDeviceReady() {
        /* ===============
        // Bind Ajax calls with
        // activity Indicator
        // =============== */
        $(document).ajaxStart(function() {
            navigator.notificationEx.activityStart();
        }).ajaxStop(function() {
            navigator.notificationEx.activityStop();
        });
    //other stuff
    }
    

    This way, all ajax will be shown in the activity when happening.

    Update:
    For Zeptojs – on version 0.8 or superior ajax global implemented only on v0.8, use the following:

    function onDeviceReady() {
        /* ===============
        // Bind Ajax calls with
        // activity Indicator - ZEPTO
        // =============== */
        $(document).on('ajaxStart',function() {
            navigator.notificationEx.activityStart();
        }).on('ajaxStop',function() {
            navigator.notificationEx.activityStop();
        });
    //other stuff
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my scenario: I have made a regular DLL in C++ (using VS2008) which
A serious scenario I have encountered and which is totally made my Script handicapped,
Scenario I have a DevExpress DataGrid which is bound to a DataSet in C#.
Scenario: I have created a database table. And when I tried to add a
Scenario: I have a contact form on my web app, it gets alot of
Here is my scenario: I have my-jsf-app.war (JSF 1.2 application) and daos-and-entities.har (Hibernate 3.3.1)
consider the following scenario: I have a storyboard-based app. I add a ViewController object
Here is a scenario: User installs .NET application that you have made. After some
The scenario is I have received a file for processing via my web service.
i have made an android application and in it , there is one scenario

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.