Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Reflection not fully implemented in Android 2.2?
- if(field.getType() == java.util.ArrayList.class)
- className = ((ParameterizedType)field.getGenericType()).toString();
- public class ReproduceBugActivity extends Activity {
- private static final String TAG = "ReproduceBugActivity";
- private ArrayList<Object> mArrayList;
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- try {
- String className = null;
- Field field = getClass().getDeclaredField("mArrayList");
- if (field.getType() == java.util.ArrayList.class)
- className = ((ParameterizedType)field.getGenericType()).toString();
- Log.i(TAG, "className = " + className);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- java.lang.NullPointerException
- at org.apache.harmony.luni.lang.reflect.ListOfTypes.length(ListOfTypes.java:47)
- at org.apache.harmony.luni.lang.reflect.ImplForType.toString(ImplForType.java:83)
- at com.reproducebug.ReproduceBugActivity.onCreate(ReproduceBugActivity.java:23)
- I/ReproduceBugActivity(23449): className = java.util.ArrayList<java.lang.Object>
Add Comment
Please, Sign In to add comment