@romainguy recently told me about ViewServer, a utility class he open sourced, which can be used to enable HierarchyViewer on your apps even if you don't have a rooted / engineer build phone.
The source is here: https://github.com/romainguy/ViewServer/tree/master/src/com/android/debug/hv
I think it could be nice to bake such a feature into AndroidAnnotations using a specific annotation (such as @DebugView), e.g. :
@DebugView
@EActivity
public class MyActivity extends Activity {
}
This would automatically enable the ViewServer on the activity, ie doing this :
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set content view, etc.
ViewServer.get(this).addWindow(this);
}
@Override
public void onDestroy() {
super.onDestroy();
ViewServer.get(this).removeWindow(this);
}
@Override
public void onResume() {
super.onResume();
ViewServer.get(this).setFocusedWindow(this);
}
Also note that android:debuggable must be set to true in the AndroidManifest.xml for the ViewServer to work.
Should we issue a compile warning on a ViewServer annotation if android:debuggable is false ?