1

i want to return a list with all public methods of a android resource, as methodname + argumets, for example open(int cameraId), release(), setDisplayOrientation(int degrees) and so on for the camera. So i created this method

public List<String> getPublicMethods(String api) throws ClassNotFoundException {

    Class clazz = Class.forName("android.hardware.Camera");
    Method[] publicMethods= clazz.getDeclaredMethods();


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

    for (Method met : publicMethods) 
        list.add(met.getName()); 
    return list;
}

I can return only a list. How do i change it so it returns the arguments too?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
julia
  • 13
  • 2

1 Answers1

0

Consider returning a HashMap. That will give you flexibility to return both of the the objects. Method name will be used as Key and then Parameters as a List. Something like

Map<String, List<Object>> values = new HashMap<>();


public Map<String, List<Object>> getPublicMethods(String api) throws ClassNotFoundException {

    Map<String, List<Object>> values = new HashMap<>();

    Class clazz = Class.forName("android.hardware.Camera");
    Method[] publicMethods= clazz.getDeclaredMethods();

    List<Object> listArgument = //Get Arguments Here

    for (Method met : publicMethods) 
        values.put(met.getName(), listArgument); 
    return values;
}

String for Method Name List for List of Arguments.

Alex
  • 1,406
  • 2
  • 18
  • 33