Friday, 31 August 2018

Kony Objects Service Example Code?


OnlineObjectService  programmatic access to backend data with online


function createDatabObject(){

  var objSvc = kony.sdk.getCurrentInstance().getObjectService("DevDBaccess", {"access":"online"});
  var dataObject = new kony.sdk.dto.DataObject("tbl_register");
  dataObject.addField("name","your name");
  dataObject.addField("username","your username");
  dataObject.addField("password","your password");
  dataObject.addField("phoneno","your phone no here");
  dataObject.addField("address","your address here");
  var options = {"dataObject":dataObject};

  objSvc.create(options,
                function(res){alert("Record created");},
                function(err){alert("Error in record creation");}
               );
}


Kony Integration service call example?



Example : 1

function gblServiceCall(){
  try{

  var inputParams = {};

or 
  var inputParams = {"userid":"111111"};
    mfintegrationsecureinvokerasync(inputParams, serviceName , operationName,successcallbackFunction,errorcallbackFunction);
  }catch(err){
    kony.print("Error Response"+JSON.stringify(err));
  }
}

function successcallbackFunction(code,res){
  
  try{
    kony.print("Response Code : "+code);
    alert("Response Code : "+JSON.stringify(res));
  }catch(err){
    kony.print(err);
  }
}


function errorcallbackFunction(errResponse){
  try{
    kony.print("Response Code : "+JSON.stringify(errResponse));
  }catch(err){
    kony.print(err);
  }
}



Example : 2



function integrationServiceCall(){
  try{
    
    showloadingScreen(); //loading screen
    var operationName =  "your operation name";
    var  data= {"accessToken": "","deviceId": ""};
    var headers= {};
    var serviceName = "Your Service Name";
    var integrationObj =  KNYMobileFabric.getIntegrationService(serviceName);
    integrationObj.invokeOperation(operationName, headers, data, operationSuccess, operationFailurecb);


  }catch(err){
    konyConsole("Exception while occuring : "+printJSONSTRING(err));
  }
}



function operationSuccess(res){
  
  dismissLoading();
  kony.print("Get Country List Service Calling");
  kony.print("operationSuccess Country is "+JSON.stringify(res));
  

  
}
function operationFailurecb(errRes){
  
  dismissLoading();
  kony.print("operationFailurecb Error is"+printJSONSTRING(errRes));
  
  if(errRes.errcode === 1011){
    alert("Device has no WIFI or mobile connectivity. Please try the operation after establishing connectivity.");
  }
}


function showloadingScreen(){
  try{
     kony.application.showLoadingScreen("","Loading...", constants.LOADING_SCREEN_POSITION_ONLY_CENTER, true, true, null);
  }catch(errLoadScrn){
    kony.print(printJSONSTRING(errLoadScrn));
  }
}

function dismissLoading(){
  kony.application.dismissLoadingScreen();

}







Wednesday, 29 August 2018

How to make auto paging segment using timer?


Auto paging segment using timer in Kony Reference Architecture.

define(function(){

  var count = 0;
  var setDataList = [{
    imgPageViewer : "imgone.png"
  },{
    imgPageViewer : "imgtwo.png"
  },{
    imgPageViewer : "imgthree.png"
  }];

  return {
    onNavigate : function(context){
      this.onbindWidgets();

    },
    onbindWidgets : function(){

      this.view.segPageViewer.setData(setDataList);
      this.onPagerViewrStart();
    },
    onPagerViewrStart : function(){
      try{
        kony.timer.schedule("mytimer12",this.timerFuncsses,8,true);
      }catch(err){
        kony.print("timeStarter : "+JSON.stringify(err));
      }
    },
    timerFuncsses : function(){

      count = Number(count+1);
      if(count>2){
        count = 0;
        this.view.segPageViewer.selectedRowIndex = [0,count];
      }else{
        this.view.segPageViewer.selectedRowIndex = [0,count];
      }
    }
  };

});





Monday, 27 August 2018

Form Controller Structure Example?


Form Controller Structure like: 


Example Step One :- ( Controller Class)

define(function() {

  var _controller;
  var _countryData;
  function _updateUI() {

    /*====
    method to load the data into the Widgets UI
    ====*/
   
    _controller.view.segCountryList.widgetDataMap = {
      "id" : "id",
      "lblCountryName" : "name"
    };

    _controller.view.segCountryList.setData(_countryData);
  }

  function _loadData() {

    var CountryModel = require("countrymodel");
    _countryData = CountryModel.getAll(); 
    konyConsole("Data : "+JSON.stringify(_countryData));
    _updateUI();
  }

  function _bind() {
    alert("binding");
  }

  function onDestroy() {
    kony.print("onDestroy()");    //Cleanup
  }

  function onNavigate(params) { 
    kony.print("onNavigate()");
    _controller=this; //capture reference to controller
    _bind();
    _loadData();
    //retrieve data from model, setup the ui
  }

  return { 
    onNavigate : onNavigate,
    onDestroy: onDestroy
  };
});


//require : controller is :(in require modules) ==> model Class


define(function () {
  /* jshint esnext: true */ 

  var staticData = [   
    { id: 1, name: "India" },   
    { id: 2, name: "France" },   
    { id: 3, name: "Germany" },   
    { id: 4, name: "UK" },   
    { id: 5, name: "Italy" },   
    { id: 6, name: "Chile" },   
    { id: 7, name: "Brazil" },   
    { id: 8, name: "USA" }, 
    { id: 9, name: "Canada" } 
  ];   

  function getAll() {   
    return staticData; 
  }   
  function getById(id) {   
    return staticData.find(country => country.id===id); 
  }   

  return {     
    getAll : getAll,     
    getById : getById 
  };
});





Tuesday, 21 August 2018

Kony Interview Question's and Answer's



1.  What is Kony app lifecycle Events?                                                                           
         An application an activity from is launched and enters into a device's memory to when it is exited and released from memory is referred to as the app's lifecycle.
Set action sequences for the app's lifecycle is :

  • Pre Appinit. Pre-initialization.
    • This event consists of any logic that needs to be executed before the initialization of forms.
  • Init
    •      Is generated by the code and consists of the form and skin initialization data
  • Post Appinit. Post-initialization
    •      This function to define logic that needs to be executed before the first form is shown and after the application is initialized
  • App Service
    •       This function also returns the form handle and launching of background services(launching another form)
  •  Deeplink
    •       Refers to creating services links in your app that enable third-party native and browser applications to connect to your app.  More...
2. Why using Gesture in Kony?
       A gesture is an action associated with movement of a mouse or a touch screen action

        Currently, Kony Platform supports only Tap, Swipe, Longpress, Pan, Rotation, Pinch, and 3D Touch gesture types. 3D Touch is supported only in iOS 9.0 and later

       The gesture methods is : 

              1. addGestureRecognizer
              2. removeGestureRecognizer

3. Widgets types in kony?
 
       Basic Widgets :   
            exp : Alert,App Menu,Button,Calendar,ComboBox and etc...

       Container Widgets :
            exp : FlexForm,FlexScrollContainer,NativeContainer,TabPane and etc..

       Advanced Widgets :
            exp : Browser,Camera,HorizontalImageStrip,Map,ObjectSelector3D,Phone and etc...
    
4. Types of Alerts in Kony?

information - an informative message is displayed on the screen. This message can be in turn a warning or a success message.

confirmation - a confirmation message with Yes and No options is displayed on the screen.

error - an error message is displayed on the screen.

5. what is use of makeAffineTransform function?

           Creates a transformation object that can be used in an animation definition.

  Ex : kony.ui.makeAffineTransform();


6.  Form LifeCycle Event?


6.  Form LifeCycle Event?

1) init 
a) Initializations required for the form. 
b) Init initializes the form and any widgets.
2) preShow 
a) called just before a form is visible on the screen.
3) postShow
a) called immediately after the form is visible on the screen.
4) onHide 
a) called when the form goes out of the screen. A form can go out of the screen when another form is to be shown.
5) onDestroy 

a) called when a form is destroyed.

a) called when a form is destroyed.






Kony App Lifecycle Events

Set App Lifecycle Events

The arc of activity from the time an app is launched and enters into a device's memory to when it is exited and released from memory is referred to as the app's lifecycle. Particular phases characterize the lifecycle of an app, such as the following (which are explained in greater detail later): Pre-initialization, Post-initialization, App Service, Deeplink, On View State Change, and On Search.
For any of these phases, you can design your app to launch action sequences, as your app requires. App lifecycle action sequences are supported for all four available app channels, namely Mobile, Tablet, Desktop, and Watch.
To set app lifecycle events, do the following:
  1. In Kony Visualizer, open the project for which you want to set action sequences for the app's lifecycle.
  2. From the Project tab of the Project Explorer, click either MobileTabletDesktop, or Watch. The Visualizer Canvas displays text indicating that you can define app life cycle events from the Properties Editor.
  3. On the App Events tab of the Properties Editor, click the Edit button of the app lifecycle phase for which you want to create action sequences. Doing so opens the Action Editor. All four available app channels consist of the following app lifecycle phases:
    • Pre Appinit. Pre-initialization, which refers to that part of the app lifecycle after the app is launched but prior to it loading.
    • Post Appinit. Post-initialization, which refers to that part of the app lifecycle after the app has loaded, but prior to the displaying of data.
    • App Service. Refers to the launching of background services that the app relies upon.
    • Deeplink. Refers to creating services links in your app that enable third-party native and browser applications to connect to your app, providing a unified and seamless experience.
    Additionally, the Tablet channel includes the following two app lifecycle phases:
    • On View State Change. Refers to any time the state of the view changes between portrait and landscape, or between normal view and full screen.
    • On Search. Refers to any time a search is initiated.
  4. Using the Action Editor, create the action sequences you want. For more information, see Add Actions.

Wednesday, 1 August 2018

Navigation from one form to another form in kony



Form Navigation :

          var nextForm = new kony.mvc.Navigation("form Name");
          nextForm.navigate();


//form Name : passing your next form name.


Example : 2 Passing data from one form to another form


Sending :  form 1

        var nextForm = new kony.mvc.Navigation("frmSecondScreen");
        var myObj = {lbl1:"chandru"}; 
        nextForm.navigate(myObj);


Receiving : form 2

onNavigate : function(context){
       alert(JSON.stringify(context));
    }



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 ...