Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery mobile activity indicator not showing in android

I try to show activity indicator in my application. I am using activity.js for activity indicator. That one is working fine in browser and iPhone But its not working in Android devices.

I dont know why indicator does not working in android devices.

Here is my sample code for activity indicator:

function showIndicator() {
    console.log("inside show indicator");
    applyOverLay();
    var showIndicator = document.createElement("div");
    showIndicator.setAttribute("class", "activity-indicator");
    document.body.appendChild(showIndicator);
    $('.activity-indicator').activity({
        width: 5,
        space: 1,
        length: 3,
        color: '#fff'
    });
}

function applyOverLay() {
    var overlay = document.createElement("div");
    overlay.setAttribute("id", "overlayAttr");
    overlay.setAttribute("class", "overlay");
    document.body.appendChild(overlay);
}

function hideindicator() {
    $('.activity-indicator').activity(false);
    setTimeout(function() { $(".activity-indicator").empty().remove(); }, 0);
    setTimeout(function() { $(".overlay").empty().remove(); }, 0);
}

function loadhtmlpage() {   
    //location.href='#refillReminder';
    $.mobile.changePage("#refillReminder"); 
    showIndicator();
    hideindicator();
}

style.css:

.activity-indicator {
    padding: 10px;
    position: absolute;
    top: 50%;
    left: 45%;
    z-index: 1001;
}
like image 798
user Avatar asked Nov 22 '12 09:11

user


1 Answers

I have used the following code to show the native activity indicator on Android..try this.. it may help..

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    $(document).bind("ajaxSend", function() {
        navigator.notification.activityStart("App Name","Loading...");
     }).bind("ajaxStop", function() {
        navigator.notification.activityStop();
    }).bind("ajaxError", function() {
        navigator.notification.activityStop();
     });    

}
like image 62
user Avatar answered Sep 25 '22 01:09

user