Software Archive
Read-only legacy content
17061 Discussions

External API not supporting in .apk file

Spaceforhost_K_
Beginner
372 Views

hi,

We have developed a new APK for android through IntelXDK and it is working fine through APP Preview app. 

We have used this application for checking the net connection and current location while loading this application 

Secondly we put some external database connection JSON and it is not working while building .apk file.

Here with attaching the .apk file for checking,

Please give solution as early as possible.

 

0 Kudos
2 Replies
Barry_Johnson
New Contributor I
372 Views

When you say "not working" can you describe how it is not working? Is the AJAX call not being made?

0 Kudos
Spaceforhost_K_
Beginner
372 Views

hai,

 

Our index.html page is here,

 

<!DOCTYPE html>
<html>

                <head>
                                <meta charset="UTF-8">
                                <link rel="stylesheet" type="text/css" href="app_framework/2.1/css/af.ui.min.css">
                                <link rel="stylesheet" type="text/css" href="app_framework/2.1/css/icons.min.css">
                                <title>Suraksha</title>
                                <meta http-equiv="Content-type" content="text/html; charset=utf-8">

 <!--
  * The "meta viewport" tag (below) helps your app size appropriately to a device's ideal viewport.
  * Note that Windows device viewports work better when initialized using the @viewport CSS rule.
  * For a quick overview of "meta viewport" and @viewport, see this article:
  *   http://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/quick-tip-dont-forget-the-viewport-meta-tag
  * To see how it works, try your app on a real device with and without a "meta viewport" tag.
  * Additional useful references include:
  *   http://www.quirksmode.org/mobile/viewports.html
  *   http://www.quirksmode.org/mobile/metaviewport/devices.html
  *   https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html
-->

                                <!-- <meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1"> -->
                                <meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=no">
                                <!-- <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=yes, minimum-scale=1, maximum-scale=2"> -->

                                <style>
                                                /* following three (cascaded) are equivalent to above three meta viewport statements */
                                                            /* see http://www.quirksmode.org/blog/archives/2014/05/html5_dev_conf.html */
                                                            /* see http://dev.w3.org/csswg/css-device-adapt/ */
                                                                @-ms-viewport { width: 100vw ; min-zoom: 100% ; zoom: 100% ; }          @viewport { width: 100vw ; min-zoom: 100% zoom: 100% ; }
                                                                @-ms-viewport { user-zoom: fixed ; min-zoom: 100% ; }                   @viewport { user-zoom: fixed ; min-zoom: 100% ; }
                                                                /*@-ms-viewport { user-zoom: zoom ; min-zoom: 100% ; max-zoom: 200% ; }   @viewport { user-zoom: zoom ; min-zoom: 100% ; max-zoom: 200% ; }*/
                                                                /* css for custom list item, modify as needed */        
#afui #listview .list li {padding:10px 20px 10px 10px}
.list-image {float:left;width:50px;height:50px}
.list-text {margin-left:60px;min-height:50px} 
#myImage { display:none;width:150px;height:150px;text-align:center; }
.capitalize { text-transform: capitalize;}
::-webkit-input-placeholder { color: #b43504;}
.widthHalf {  width:50%;text-align:center;}
.headColor {  color : #b43504;text-align:center;font-weight:bold;}

                                </style>

                                <link rel="stylesheet" href="css/app.css">
                                <link rel="stylesheet" type="text/css" href="css/index_main.less.css" class="main-less">

                                <!-- IMPORTANT: Do not include a weinre script tag as part of your release builds! -->
                                <!-- Place your remote debugging (weinre) script URL from the Test tab here, if it does not work below -->
            <script src="http://debug-software.intel.com/target/target-script-min.js#UAJ9QAklGVX_lbyr7RsW-OuK3fOO1NeZsR4ULmzrSTI"></script>
                                
                                <!-- <script src="http://debug-software.intel.com/target/target-script-min.js#insertabiglongfunkynumberfromthexdkstesttab"></script> -->

                                <!-- Recommended location for your JavaScript libraries -->
                                <!-- These library references (below) are just examples to give you the general idea... -->
                                <!-- <script src="lib/mc/hammer.js"></script> -->
                                <!-- <script src="lib/ft/fastclick.js"></script> -->

                                <!--
  * cordova.js is a phantom lib for "Cordova HTML5 web app," it does nothing in a "Standard HTML5 web app"
  * Seeing a "Failed to load resource: net::ERR_FILE_NOT_FOUND" message caused by this "cordova.js" script?
  * The cordova.js script is required if you convert your "Standard HTML5" project into a "Cordova" project.
  * You can safely ignore the error or comment out this line if you will not be developing a Cordova app.
-->
                                <script src="cordova.js" id="xdkJScordova_"></script>

                                <script src="js/app.js"></script>
                                <!-- for your event code, see README and file comments for details -->
                                <script src="js/init-app.js"></script>
                                <!-- for your init code, see README and file comments for details -->
                                <script src="xdk/init-dev.js"></script>
                                <!-- normalizes device and document ready events, see file for details -->

                                <!--            
            You may substitute jQuery for the App Framework selector library.
            See http://app-framework-software.intel.com/documentation.php#afui/afui_jquery
        -->
                                <script type="application/javascript" src="app_framework/2.1/appframework.js"></script>
                                <script type="application/javascript" src="app_framework/2.1/appframework.ui.js" data-ver="1"></script>
                                <script type="application/javascript" src="app_framework/themeRelease.js"></script>
                                
                                
                                
       <script>    
        function onDeviceReady(){ 
            
        var networkState = navigator.connection.type;

    var states = {};
    states[Connection.UNKNOWN]  = 'Unknown connection';
    states[Connection.ETHERNET] = 'Ethernet connection';
    states[Connection.WIFI]     = 'WiFi connection';
    states[Connection.CELL_2G]  = 'Cell 2G connection';
    states[Connection.CELL_3G]  = 'Cell 3G connection';
    states[Connection.CELL_4G]  = 'Cell 4G connection';
    states[Connection.CELL]     = 'Cell generic connection';
    states[Connection.NONE]     = 'No network connection';

    
    if(states[networkState]=='No network connection')
    {
        alert("Plase enable internet");
    }
    if(navigator.connection.type==Connection.NONE)
    {
        alert("There is no internet connection");
    }
    
    else{            
        
            
            var string = device.uuid;            
            $.ui.launch();
            intel.xdk.device.hideSplashScreen();
            getLocation();
            fetchsthreesurkshaoffense();
            fetchDistrict();
        }
        }
        document.addEventListener("intel.xdk.device.ready", onDeviceReady, false);
    </script>
<!-- end Intel XDK code -->
    
    <script>   
        $.ui.autoLaunch = false; 
         $.ui.backButtonText = "Back";       
        $(document).ready(function(){
            $.ui.launch();
                        
             $("#register").on("click", function(){
                 
                signUp();
            });
            
            
                        
          function startApp(){
            
            $.ui.clearHistory();  // clears all back button history
            
            // app code here
          }
          
           $("#sthreesuraksha").on("click", function(){
                PostSurakshaNews();
            });
            function PostSurakshaNews(){
                
                $.ui.loadContent("PostNews", null, null, "fade");
            }
            
        });
    </script> 
    
    
                </head>

                <body id="afui">

                                <!-- IMPORTANT: Do not include a weinre script tag as part of your release builds! -->
                                <!-- Place your remote debugging (weinre) script URL from the Test tab here, if it does not work above -->
                                <!-- <script src="http://debug-software.intel.com/target/target-script-min.js#insertabiglongfunkynumberfromthexdkstesttab"></script> -->

                                
                <div id="content" style=""> 
        
    <!--Tab View Pages-->
        <div class="panel" title="Home" id="Main" data-tab="Main" selected="true">
            <header>
                <h1 class="h1">Suraksha</h1>
            </header>
            <p>
          <div style="text-align:center">
            <br>           
            <p class="headColor">Sign Up</p>
            <br>            
          </div>
            <input name="name" id="name" type="text" placeholder="Name" class="capitalize"/>
            <input name="email" id="email" type="text" placeholder="Email" />
            <input name="mobile" id="mobile" type="text" placeholder="Mobile" />
            <select name="district" id="district">
            <option value="0">Choose District</option>
            </select>
            <input name="location" id="location" type="text" />
            <div align="center"><a class="button block orange widthHalf" href="#" id="register">Register</a></div>
            </p>
        </div>
        
         <!-- Home App View -->
        <div class="panel" title="Start" id="Home" data-load="startApp">
         <header>
                <h1 class="h1">Sthree Suraksha</h1>
            </header>
            <p>
            
            <div style="text-align:center;color : #b43504">
            <br>   
                
            <a href="#" id="sthreesuraksha"><img src="images/sreesurakshaLogo.png" width="128" height="128" alt="sreesuraksha"></a>
            <br> 
            <p>Tap to Continue... </p>  <br>           
            <p>This App is mainly aimed for sthree suraksha, Everyone download app from playstore and installed.Users can post their probems faced from husbands or from public can post from our App. And it can send from the corresponding District Police Chief's.</p>
            <br>           
            <p>App Developed By:</p>
            <p>Biospace Technologies Pvt Ltd</p>
          </div>
            
          </p>
        </div>
        
        <div class="panel" title="PostNews" id="PostNews" data-tab="PostNews">
            <header>
                <h1 class="h1">Complaints</h1>
            </header>
             <p style="color : #b43504;text-align:center;font-weight:bold;padding-bottom:10px;">Post Your Complaints</p>
            <p>
            <a class="button block grey icon camera" href="#" onClick="takePicture()" id="takepic">Take a photo</a>
            <br>
            <div align="center"><img id="myImage" name="myImage"/></div>
           <br>
            <select name="sthreeoffense" id="sthreeoffense">
            <option value="0">Choose Offense</option>
             <option value="1">test</option>
            </select>    
                 
            <textarea name="description" id="description" rows="4" placeholder="Description..."></textarea>
            <input name="Postreqlocation" id="Postreqlocation" type="text" readonly/>
            <div align="center"><a class="button block orange widthHalf" href="#" id="Send">Send</a></div>
            </p>
        </div>
        
        
        <div class="panel" title="About" id="About" data-tab="About">
            <header>
                <h1>About</h1>
            </header>
            <p>This is view for second Tab</p>
        </div>
        
        <div class="panel" title="News" id="News" data-tab="News">
            <header>
                <h1 class="h1">Latest Blog News</h1>
            </header>
            <p>
            <!-- Load News -->
            <ul class="list">
                <li>
                    <a href="#item1">
                        <img class="list-image" src="data/male_user_icon.svg" />
                        <div class="list-text"><b>username1</b><br>Placeholder text for this list item 1. This sections can modified for your need.</div>
                    </a>
                </li>
                <li>
                    <a href="#item2">
                        <img class="list-image" src="data/male_user_icon.svg" />
                        <div class="list-text"><b>username2</b><br>Placeholder text for this list item 2. This sections can modified for your need.</div>
                    </a>
                </li>
                <li>
                    <a href="#item3">
                        <img class="list-image" src="data/female_user_icon.svg" />
                        <div class="list-text"><b>username3</b><br>Placeholder text for this list item 3. This sections can modified for your need.</div>
                    </a>
                </li>
                <li>
                    <a href="#item4">
                        <img class="list-image" src="data/male_user_icon.svg" />
                        <div class="list-text"><b>username4</b><br>Placeholder text for this list item 4. This sections can modified for your need.</div>
                    </a>
                </li>                
            </ul>
           <!-- Load News End -->
             
             
             
        <!-- Details View Pages for each News items-->
             
        <div class="panel" title="Item 1" id="item1">
             <header><a class="button backButton">Back</a>
                <h1>Latest Informations</h1>
            </header>
            <p>This is detail view for Item 1</p>
        </div>
        
        <div class="panel" title="Item 2" id="item2">
         <header><a class="button backButton">Back</a>
                <h1  class="h1">Latest Blog News</h1>
          </header>
        
          <p>This is detail view for Item 2</p>
        </div>
        
        <div class="panel" title="Item 3" id="item3">
        
         <header><a class="button backButton">Back</a>
                <h1>Latest Blog News</h1>
          </header>
            <p>This is detail view for Item 3</p>
        </div>
        
        <div class="panel" title="Item 4" id="item4">
        
         <header><a class="button backButton">Back</a>
                <h1>Latest Blog News</h1>
          </header>
            <p>This is detail view for Item 4</p>
        </div>
        <!-- Detail View Pages for each News items  end -->
        </p>
        </div>
        
        <div class="panel" title="Profile" id="Profile" data-tab="Profile">
            <header>
                <h1 class="h1">Profile</h1>
            </header>
            <p>
            <textarea name="address" id="address" rows="4">Address</textarea>
            <input name="job" id="job" type="text" placeholder="Designation / Job" />
            
           <div align="center"> <a class="button block  orange widthHalf" href="#" id="Send">Update</a>    </div>        
            </p>
        </div>
        
    </div>
      <!--Footer with Tabs or Navigation bar -->
    <div id="navbar">
        <a href="#Main" id='Main' class="icon home" data-transition="none">Home</a>
        <a href="#About" id='About' class="icon loading" onClick="fetchsthreesurkshaoffense()" data-transition="none">About</a>
        <a href="#News" id='News' class="icon chat" data-transition="none">News</a>
        <a href="#Profile" id='Profile' class="icon user" data-transition="none">Profile</a>
    </div>
    

  </body>
</html>

 

 

App.js files

 

 

function takePicture(){

navigator.camera.getPicture(onSuccess, onFail, { quality: 70,destinationType: Camera.DestinationType.DATA_URL});
}

function onSuccess(imageData) {
    //alert(imageData);
    var image = document.getElementById('myImage');    
    image.src = "data:image/jpeg;base64," + imageData;
    image.style.display = 'block';
}

function onFail(message) {
    alert('Failed because: ' + message);
}

function getLocation(){
    
    if(navigator.geolocation)
    {
      navigator.geolocation.getCurrentPosition(showGPS,gpsError);    
    }
    else {
        alert("No GPS Functionality.");
    }
    function gpsError(error){
        alert("GPS Error:" + error.code+","+error.message);
    }
    function showGPS(position){
        
        var latitude=position.coords.latitude;
           var longitude=position.coords.longitude;
        
        
        
         var url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng='+ latitude +','+longitude +'&sensor=false';

    $.ajax({
    dataType: "json",
    url: url,
    async: false,
    scriptCharset: "utf-8",
    contentType: "application/json; charset=utf-8",
    success: function(json) 
    {
       
       
       var found_city = false;
        if (json && json.results.length > 0)
        {
           var geoaddress= json.results[1].formatted_address;
           var location = document.getElementById('location');    
           location.value = geoaddress;
           
           var Polocation = document.getElementById('Postreqlocation');    
           Polocation.value = geoaddress;
            
         }
        if (!found_city) {
           // alert("City not found!");
        }
    }
})
.fail(function( jqxhr, textStatus, error ) {
    var err = textStatus + ", " + error;
    alert("Request Failed: " + err );
});  

   
    }
    
    
}

function signUp(){  
            
            // signup code    
            
    var name = $('#name').val();
    var email = $('#email').val();
    var mobile = $('#mobile').val();
    var district = $('#district').val();
    var location = $('#location').val();                
    var device_id = device.uuid;
    
    if(name.length <1)
                 {
                    alert("Please enter your name");
                    name.focus();
                    return false; 
                 }
                
                if(email.length <1)
                 {
                    alert("Please enter your email_id"); 
                    email.focus();
                    return false; 
                 }
                else
                {
                    //email=email.value
                    emailHasAt=email.indexOf("@");
                    emailHasPeriod=email.indexOf(".");
                    if((emailHasAt==-1)||(emailHasPeriod==-1))
                        {
                            alert("Not a valid email ID");
                            email.focus();
                            email.value="";
                            return false;
               }
               }
                var iChars = "!#$%^&()+=[]\\\';/{}|\":<>?";
               for (var i = 0; i < email.length; i++) {
                 if (iChars.indexOf(email.charAt(i)) != -1) {
                 alert ("Your Email has special characters. \nThese are not allowed.\n Please remove them and try again.");
                 return false;
                 }
                  }
               if(mobile.length <1)
                {
                   alert("Please enter your Mobile number");
                   mobile.focus(); 
                   return false;                     
                }
               if(mobile.length <10)
                {
                   alert("Not a valid Mobile number");
                   mobile.focus(); 
                   return false;                     
                }
               if(mobile.length >10)
                {
                   alert("Not a valid Mobile number");
                   mobile.focus(); 
                   return false;                     
                }
               
               if (district == '0') {
                   error = 1;
                   alert('You should select a district.');
                   return false;
                }
               else{
                            
                $.ajax({
                  type: "POST",                 
                  crossdomain: true,                    
                  url: "http://suraksha.org.in/suraksha_rest/api.php?method=userReg",
                  data: { 
                      name: name,
                      email:email,
                      mobile:mobile,
                      district:district,
                      location:location,                     
                      device_id: device_id
                  },
                    success:function(msg){  
                         $.ui.loadContent("Home",null,null,"fade");
                    }   
                });
               }
    
}

function fetchsthreesurkshaoffense(){
    
    var urls = 'http://suraksha.org.in/suraksha_rest/api_suraksha.php';
         
    $.ajax({
    type: "POST",
    crossdomain: true,
    dataType: "json",
    url: urls,
    data: { actioncode: 3},
    success: function(json) 
    {    
              
      var arr_le = json.data.length;
      
        if(arr_le!=0){
            for (i=0;i<json.data.length;i++)
            {    
                var optn = document.createElement("OPTION");
                optn.value = json.data.category; 
                optn.text = json.data.s_name;                
                document.getElementById('sthreeoffense').options.add(optn);
            }
        }       
      }
     });    
}

function fetchDistrict(){    
        
    var urlP = 'http://suraksha.org.in/suraksha_rest/api_suraksha.php';
     
   $.ajax({
    type: "POST",
    crossdomain: true,
    dataType: "json",
    url: urlP,
    data: { code: 4},
    success: function(myarray) 
    {    
           
      var arr_le = myarray.datarec.length;
           //alert(arr_le);
        if(arr_le!=0){
            for (var i=0;i<myarray.datarec.length;i++)
            {    
                var optn = document.createElement("OPTION");
                optn.value = myarray.datarec.category; 
                optn.text = myarray.datarec.districtName;                
                document.getElementById('district').options.add(optn);
            }
        }       
      }
     });
}

 

 

 

0 Kudos
Reply