androidffitemenos-quantum

How to pass KonyMain.getActivityContext() from android for kony ffi


Please check below code

package com.firebaseio.httpsfirbasenosql.auth;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;

public class AuthClass {


    public static void callAuth(Context con, String url) {
        boolean isAppInstalled = appInstalledOrNot(con,"com.android.chrome");


        if(isAppInstalled) {

            Intent intent=new Intent(Intent.ACTION_VIEW,Uri.parse(url));
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.setPackage("com.android.chrome");
            try {
                con.startActivity(intent);
            } catch (ActivityNotFoundException ex) {
                // Chrome browser presumably not installed so allow user to choose instead
//                Log.i("Auth","ActivityNotFoundException");
                intent.setPackage(null);
                con.startActivity(intent);
            }

        } else {
//            Log.i("Auth","Application is not currently installed.");
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
            con.startActivity(browserIntent);
        }
    }

    private static boolean appInstalledOrNot(Context con, String uri) {

        PackageManager pm = con.getPackageManager();
        try {
            pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
            return true;
        } catch (PackageManager.NameNotFoundException e) {
        }
        return false;
    }
}

From Kony App I called callAuth function with 2 parameters, 1st argument is context and 2nd string.

Please help me how to app context from kony app or how to call kony context in android static class.


Solution

  • You don't have to pass the context. You can always get it using KonyMain.getActivityContext(). For this class, you must add konywidgets.jar to your build path or to the dependent libraries. You can find this jar file in the following path : /temp//build/luaandroid/dist//libs