function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Prakhar KPrakhar K 

In contact explorer app (Hybrid) (Android) onDeviceReady function is not firing?

After compiling and running the contact explorer sample app (hybrid), in index.html the onDeviceReady function is not firing nor it is giving any error in logCat in eclipse ADT?
I am using cordova 2.2.0.js using API 16 4.1.2 ?below is the code of index.html

 
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0; user-scalable=no" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">

    
    <link rel="stylesheet" href="jquery/jquery.mobile-1.3.1.min.css" />
    <script src="jquery/jquery-2.0.0.min.js"></script>
    <script src="jquery/jquery.mobile-1.3.1.min.js"></script>
       

<script src="cordova-2.2.0.js"></script>

    <script src="cordova.force.js"></script>

   
    <script src="forcetk.mobilesdk.js"></script>


    <style>
      .logWindow {display:none; width:700px;}
      .logWindow > p {padding:0px; margin:0px; word-wrap:break-word;}
    </style>

    <script>

   
    // The version of the REST API you wish to use in your app.
    var apiVersion = "v28.0";

    var forcetkClient;
    var debugMode = true;
    var logToConsole = cordova.require("salesforce/util/logger").logToConsole;

    jQuery(document).ready(function() {
        //Add event listeners and so forth here
        logToConsole("onLoad: Hii jquery ready");
         logToConsole("onLoad:before");
           
  document.addEventListener("deviceready",onDeviceReady,false);                             //not firing,no error in LogCat and in console//
        logToConsole("onLoad:After");

    });
   
   

    // When this function is called, Cordova has been initialized and is ready to roll
    function onDeviceReady() {
   
        logToConsole("onDeviceReady: Cordova ready");
  //Call getAuthCredentials to get the initial session credentials
        cordova.require("salesforce/plugin/oauth").getAuthCredentials(salesforceSessionRefreshed, getAuthCredentialsError);

        //register to receive notifications when autoRefreshOnForeground refreshes the sfdc session
        document.addEventListener("salesforceSessionRefresh",salesforceSessionRefreshed,false);

        //enable buttons
        regLinkClickHandlers();

    }
       

    function salesforceSessionRefreshed(creds) {
        logToConsole("salesforceSessionRefreshed");
       
        // Depending on how we come into this method, `creds` may be callback data from the auth
        // plugin, or an event fired from the plugin.  The data is different between the two.
        var credsData = creds;
        if (creds.data)  // Event sets the `data` object with the auth data.
            credsData = creds.data;

        forcetkClient = new forcetk.Client(credsData.clientId, credsData.loginUrl, null,
            cordova.require("salesforce/plugin/oauth").forcetkRefresh);
        forcetkClient.setSessionToken(credsData.accessToken, apiVersion, credsData.instanceUrl);
        forcetkClient.setRefreshToken(credsData.refreshToken);
        forcetkClient.setUserAgentString(credsData.userAgent);
    }

    function getAuthCredentialsError(error) {
        logToConsole("getAuthCredentialsError: " + error);
    }
       
    </script>
       
<!-- load our app-specific code -->

    <script src="/inline/inline.js">
     alert('invoking callMe of inline.js ...');
     callMe();
   
    </script>      

  </head>
  <body>
      <div data-role="page" data-theme="b" id="jqm-home">
          <div  data-role="header">
              <h1>Hybrid REST Explorer (SalesforceMobileSDK + Cordova + JQM)</h1>
          </div>

          <div id="#content" data-role="content">

              <p><a href="#" id="link_fetch_device_contacts" data-role="button" data-inline="true">Fetch Device contacts</a></p>
              <p><a href="#" id="link_fetch_sfdc_contacts" data-role="button" data-inline="true">Fetch SFDC contacts</a></p>
              <p><a href="#" id="link_fetch_sfdc_accounts" data-role="button" data-inline="true">Fetch SFDC Accounts</a></p>
              <p><a href="#" id="link_reset" data-role="button" data-inline="true">Reset</a></p>

              <p><a href="#" id="link_logout" data-role="button" data-inline="true">Logout</a></p>

              <div id="div_device_contact_list"></div>
              <div id="div_sfdc_contact_list"></div>
              <div id="div_sfdc_account_list"></div>

              <h3>console:</h3>
              <p id="console" class="logWindow">
              </p>
          </div>

      </div>
  </body>
</html>