如何从android为kony ffi传递KonyMain.getActivityContext()

时间:2018-03-21 06:40:59

标签: android ffi kony

请查看以下代码

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;
    }
}

从Kony App我调用了带有2个参数的callAuth函数, 第一个参数是context和2nd string。

请帮助我如何从kony应用程序中应用上下文或如何在android静态类中调用kony上下文。

1 个答案:

答案 0 :(得分:0)

您不必传递上下文。您始终可以使用KonyMain.getActivityContext()来获取它。对于此类,您必须将konywidgets.jar添加到您的构建路径或从属库中。 您可以在以下路径中找到此jar文件:/ temp // build / luaandroid / dist // libs