print All Information about a Class<?> - Android java.lang

Android examples for java.lang:Class

Description

print All Information about a Class<?>

Demo Code

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.IntentFilter;
import android.util.Log;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class Main{

    static public void printAllInform(Class<?> clsShow) {
        try {/*from  w ww. j  a va  2 s. c o  m*/
            Method[] hideMethod = clsShow.getMethods();
            int i = 0;
            for (; i < hideMethod.length; i++) {
                Log.e("method name", hideMethod[i].getName()
                        + ";and the i is:" + i);
            }
            // ?????????
            Field[] allFields = clsShow.getFields();
            for (i = 0; i < allFields.length; i++) {
                Log.e("Field name", allFields[i].getName());
            }
        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

Related Tutorials