Wednesday, 4 April 2018

Kony Tutorial

Kony-API-Toast Elements Example Code



Example Code : 

//Android Native UI Feel Toast Message 
 function toastSHOW()
 {
     var toast = new kony.ui.Toast({
         "text": "Example Toast Functionality",
         "duration":

             constants.SHORT
     });
     toast.show();
 }


Output Screen :-



Kony FFI for pdf file Share using Intent

package com.agi.pdfconverter;

import android.content.Intent;
import android.net.Uri;
import android.os.Environment;
import android.util.Base64;

import com.konylabs.android.KonyMain;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;


public class PdfFileConverter {
    static File filepath;
    static KonyMain context;


    public static void pdfConverterFile(String contentbase64, String flname) {

        context = KonyMain.getActivityContext();
        filepath = new File(Environment.getExternalStorageDirectory() +
                "/" + flname + ".pdf");
        try {
            FileOutputStream fos = new FileOutputStream(filepath);
            fos.write(Base64.decode(contentbase64, 2));
            fos.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("FFI called" + filepath);

        File externalFile = new File(Environment.getExternalStorageDirectory(),
                flname + ".pdf");
        Uri uri = Uri.fromFile(externalFile);


        /*===================content share into all application ====================*/ 
 
        /*Intent share = new Intent(); 
          share.setAction("android.intent.action.SEND"); 
          share.setType("application/pdf");
          share.putExtra("android.intent.extra.STREAM", uri); 
          context.startActivity(Intent.createChooser(share, "Share "));*/ 
         /*===================share only mail apps====================*/

        /*===================share only mail apps====================*/ 
        Intent share = new Intent(Intent.ACTION_SENDTO);
        share.setType("application/pdf");
        share.setData(Uri.parse("mailto:"));
        share.putExtra("android.intent.extra.STREAM", uri);
        context.startActivity(Intent.createChooser(share, "Share "));
        /*===================share only mail apps====================*/ 
 }

}

Kony-API for Encryption and Decryption using Algorithm


Example Code :
Key :: md4 algorithm
function genhashKEY() {
    try {  

        var algorithm_key = "md5";
        var hashKEY = kony.crypto.createHash(algorithm_key, "chandrupass");
        alert("Result : " + hashKEY);   
    } catch (err) {
        alert("Error" + err);
    }

}


Output Screen : 





Example Code : 

Key :: aes algorithm 


function genAEGALGM()
{
     var algo = "aes";

    var encryptDecryptKey = kony.crypto.newKey(
        "passphrase",
        128, {
            passphrasetext: ["inputstring1"],
            subalgo: "aes",
            passphrasehashalgo: "aes"
        });

    var inputstring = "chandrupass";

    alert("Before Encrypt : " + inputstring);
    var prptobj = {
        padding: "pkcs5",
        mode: "cbc",
        initializationvector: "1234567890123456"
    };

    var myEncryptedText = kony.crypto.encrypt(
        algo,
        encryptDecryptKey,
        inputstring,
        prptobj);

    alert("ChiperText : " + JSON.stringify(myEncryptedText));

    var myClearText = kony.crypto.decrypt(
        algo,
        encryptDecryptKey,
        myEncryptedText,
        prptobj);


    alert("Original Text : " + myClearText);

}



 Reference Link

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