Android examples for java.lang:Class
print All Information about a Class<?>
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(); } } }