I am trying to use reflection in my app. i have created one common method which hits the API on request of different classes.
try {
Class classname = Class.forName(componentName);
Object classobject = classname.newInstance();
Method method = classname.getMethod("responseString", String.class);
method.invoke(classobject, response);
} catch (Exception e) {
e.printStackTrace();
}
When i use this the viewpager in the class gives a NPE at this line
viewPager = (ViewPager) findViewById(R.id.pager_dashboard);
If i don't use reflection then this is working. What could be the problem?
Aucun commentaire:
Enregistrer un commentaire