Friday, 30 March 2018

Device information Using Kony


      Kony-Device Information Reading Programmatically

1. Example :

function ostypeINFO()
{
   var types = kony.os.deviceInfo().name;
   alert("Os Type : "+types);
   var widthandheight = kony.os.deviceInfo().deviceHeight+"x"+kony.os.deviceInfo().deviceWidth;
   alert("device widthx Height : "+widthandheight);
   var model = kony.os.deviceInfo().model;
   alert("deive model : "+model);
   var version = kony.os.deviceInfo().version;
   alert("device version : "+version);
}




 

2. Example : Device Information

 function isDeviceinfomation(){  
     var deviceINFO = kony.os.deviceInfo(); 
     alert("Device Information : "+JSON.stringify(deviceINFO));
    } 

Javascript compiler : http://rextester.com/l/js_online_compiler

Method : 1
function jsonParser() {
    var result = {
        "name": "android",
        "deviceHeight": "1184",
        "deviceWidth": 720,
        "model": "T04",
        "version": "5.1"
    };
    var jsonParse = JSON.parse(JSON.stringify(result));

    var res = jsonParse["name"];
    print("name : " +
jsonParse["name"]);
    print("deviceHeight : " +
jsonParse["deviceHeight"]);
    print("deviceWidth : " +
jsonParse["deviceWidth"]);
    print("model : " +
jsonParse["namemodel"]);
    print("version : " +
jsonParse["version"]);
}


Method 2 :

function jsonParser() {
    var jsonParse = JSON.parse('{"name":"android","deviceHeight":"1184","deviceWidth":720,"model":"T04"

,"version":"5.1"}');
    print("name : " + jsonParse.name);
    print("deviceHeight : " + jsonParse.deviceHeight);
    print("deviceWidth : " + jsonParse.deviceWidth);
    print("model : " + jsonParse.namemodel);
    print("version : " + jsonParse.version);
}


Method : 3

function jsonParser()
{  
    var result = {"name":"android","deviceHeight":1184,"deviceWidth":720,"model":"T04","version":"5.1"}
    var jsonParse = JSON.parse(JSON.stringify(result));
    print("name : "+jsonParse.name);
    print("deviceHeight : "+jsonParse.deviceHeight);
    print("deviceWidth : "+jsonParse.deviceWidth);
    print("model : "+jsonParse.namemodel);
    print("version : "+jsonParse.version);
}


Method : 4

function jsonParser() {
    var result = {
        "name": "android",
        "deviceHeight": 1184,
        "deviceWidth": 720,
        "model": "T04",
        "version": "5.1"
    }

    var jsonParse = eval("(function(){return" + JSON.stringify(result) + "})()");
    print("name : " + jsonParse.name);
    print("deviceHeight : " + jsonParse.deviceHeight);
    print("deviceWidth : " + jsonParse.deviceWidth);
    print("model : " + jsonParse.namemodel);
    print("version : " + jsonParse.version);

}


jsonParser();


Output :

name : android
deviceHeight : 1184
deviceWidth : 720
model : undefined
version : 5.1



Output Screen :-

    



2.Example : Device ID (Device Model )

//fetching Device model for an android device

function deviceUserUrgent() {
    var devID = kony.os.userAgent();
    alert("User Agent return value is::" + devID);
}
       
Output Screen :-



 
3. Example : Device Memory space

//fetching available space on device for application installation purpose
 function fetchFreeMry() {
    var freememory = kony.os.freeMemory();
    alert("Result : " + freememory);
}

//calculate bytes ;
function bytesToSize(bytes) {
   var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
   if (bytes == 0) return '0 Byte';
   var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
   return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i];
};

 

bytesToSize(126103348);
 
Result  : 121 MB

 

4. Example :  Camera Support 

//checking camera support on device
function deviceCameraSupport(){ 
  var camera_support = kony.os.hasCameraSupport();
  alert("Result : "+camera_support);
}
Output Screen :-


5. Example : GPS Support

//checking gps availability support 
function checkGPSSupport() {
    var checkgpsSupport = kony.os.hasGPSSupport();
    alert("GPS Support ==> " + checkgpsSupport);
}


Output Screen :-


 

 

Kony-Custom Popup DialogBox Sam


Custom Popup Dialog Box using Kony Visualizer 


Example Code :


 function showLogoutDialog() {
     popDialogBox.show();
 }

 function popCancelButton() {
     popDialogBox.dismiss();
 }

 function poplogoutButton() {
     alert("Logout Successfully");
 }

Output Screen :              

    

                

                       


Thursday, 29 March 2018

Loading Screen on ProgressBar Example


Loading Screen ProgressBar

       
  Syntax :

       kony.application.showLoadingScreen(skin, text, position, isBlocked, showProgressIndicator, properties)



Example :

              kony.application.showLoadingScreen("","Loading...", constants.LOADING_SCREEN_POSITION_ONLY_CENTER, true, true, null);



Reference



Wednesday, 28 March 2018

Fetech Segmentation Selected Row Value


Fetech Segmentation Selected Row Value



   Example Code :-


      var selectedindex = frmRestList.segRestList.selectedIndex[1];

      alert("Result : "+selectedindex);   //row count
     
      var selectedItems = frmRestList.segRestList.selectedItems;

      alert("Result : "+selectedItems); // JSON format Value.



   Reference

Monday, 26 March 2018

check whether a network is available for data transport on a device





Check whether a Network is Available on a Device


Note : constants.NETWORK_TYPE_ANY

      Indicates whether the device has sufficient network coverage to send data over any supported data channels. Available on Android, iOS, Windows, HTML5 SPA, Mobile Web, and Desktop Web.
    
 


Example :

 //condition checking
  if (checkIfNetworkIsAvailable()) {

      alert("Internet Connection is Available");
  } else {

      alert("No Internet Connection");
  }


  //return true or false
  function checkIfNetworkIsAvailable() {
      return kony.net.isNetworkAvailable(constants.NETWORK_TYPE_ANY);
  }



Reference 

Kony MobileFabric Implementation Steps


Kony Fabric service

URL : https://maps.googleapis.com/maps/api/place/textsearch/json?query=can&location=13.010166,80.20856&type=restaurant&key="YOUR API KEY"
Step : 1









 Step : 2



 


Step : 3 

 Example Code :
 

 function serviceCallfun() {
     try {
         var operationName = "getPlaceDetails";
         var serviceName = "PlaceDetails";
         var json_input = {
             "query": "can",
             "location": "13.010166,80.20856",
             "type": "restaurant",
             "key": "AIzaSyDKFVmU6RnuPhjOUHumOQ-ohdbIDHwKk6Y"
         };
         mfintegrationsecureinvokerasync(json_input, serviceName, operationName, operationSuccess, operationFailure);
     } catch (err) {
         alert(err);
     }
 }


function operationSuccess(status, resultant) {
    alert("result " + JSON.stringify(resultant));
}

function operationFailure(err) {
    alert("Error" + JSON.stringify(err));
}




Reference





Thursday, 22 March 2018

Kony-Programmatically Latitude and Longitude Pointing into the Map


Map Location point programmatically

Example Code : 

  
function customMapLatLngInit() {

    try {

        var pin1 = {
            id: "id1", // id is mandatory for every pin
            lat: "17.4947934",
            lon: "78.3996441",
            name: "KPHB",
            image: "mapicon.png",
            focusImage: "mapicon.png",
            desc: "guindy",
            showCallout: true,
            meta: {
                color: "green",
                label: "A"
            }
        };

        frmcustommap.mappage.locationData = [{
            lat: "13.067439",
            lon: "80.237617",
            name: "Konylabs",
            image: "mapicon.png",
            focusImage: "mapicon.png",
            desc: "1/85 Sowri Street,Chennai",
            showCallout: true,
            calloutData: {
                lbl1: "KonyLabs"
            }
        }, {
            lat: "12.9229",
            lon: "80.1275",
            name: "Konylabs",
            image: "mapicon.png",
            focusImage: "mapicon.png",
            desc: "Thambaram",
            showCallout: true,
            calloutData: {
                lbl1: "KonyLabs"
            }
        }];

        var locationData = {
            lat: "13.067439",
            lon: "80.237617",
            name: "Kids Park",
            desc: "guindy"
        };

        frmcustommap.mappage.addPin(pin1);
        frmcustommap.mappage.addPin(locationData);

    } catch (error) {
    }

}

A failure occurred while executing com.android.build.gradle.tasks

Error in Kony visualizer V9 service pack 6 and FX11  [2023-01-09 22:23:32.695] [DEBUG] ~~~~ - INFO [exec-shell] Execution failed for task ...