示例#1
0
    protected void registerClass(String p_name, String[] p_methods) {

      GodotLib.singleton(p_name, this);

      Class clazz = getClass();
      Method[] methods = clazz.getDeclaredMethods();
      for (Method method : methods) {
        boolean found = false;
        System.out.printf("METHOD: %s\n", method.getName());

        for (String s : p_methods) {
          System.out.printf("METHOD CMP WITH: %s\n", s);
          if (s.equals(method.getName())) {
            found = true;
            System.out.printf("METHOD CMP VALID");
            break;
          }
        }
        if (!found) continue;

        System.out.printf("METHOD FOUND: %s\n", method.getName());

        List<String> ptr = new ArrayList<String>();

        Class[] paramTypes = method.getParameterTypes();
        for (Class c : paramTypes) {
          ptr.add(c.getName());
        }

        String[] pt = new String[ptr.size()];
        ptr.toArray(pt);

        GodotLib.method(p_name, method.getName(), method.getReturnType().getName(), pt);
      }
    }
 private boolean isMyServiceRunning(Class<?> serviceClass) {
   ActivityManager manager =
       (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE);
   for (ActivityManager.RunningServiceInfo service :
       manager.getRunningServices(Integer.MAX_VALUE)) {
     if (serviceClass.getName().equals(service.service.getClassName())) {
       return true;
     }
   }
   return false;
 }