Java tutorial
//package com.java2s; import java.lang.reflect.Method; import android.graphics.Canvas; public class Main { private static Method methodCallDrawGLFunctionInt; private static Method methodCallDrawGLFunctionLong; static public int callDrawGLFunction(Canvas canvas, long functor) { if (methodCallDrawGLFunctionInt != null) { try { Object result = methodCallDrawGLFunctionInt.invoke(canvas, (int) functor); return (Integer) result; } catch (Throwable t) { t.printStackTrace(); } } else if (methodCallDrawGLFunctionLong != null) { try { Object result = methodCallDrawGLFunctionLong.invoke(canvas, functor); return (Integer) result; } catch (Throwable t) { t.printStackTrace(); } } return 0; } }