hierarchy is not working for my device

前端 未结 6 1260
萌比男神i
萌比男神i 2020-12-07 10:00

when I run hierarchy in terminal. it can show the interface of it, but can not connect to my device.And it can connect to virtual emulator. It remind me in terminal like tha

6条回答
  •  没有蜡笔的小新
    2020-12-07 10:54

    Romain's ViewServer project (see answer #1) works great for this. I downloaded the code, turned the project into a library project, added a dependency in my app to the new library project, and changed my app's base Activity class to subclass from this simple class:

    public class SimpleViewServerActivity extends Activity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            ViewServer.get(this).addWindow(this);
        }
    
        @Override
        protected void onDestroy() {
            super.onDestroy();
            ViewServer.get(this).removeWindow(this);
        }
    
        @Override
        protected void onResume() {
            super.onResume();
            ViewServer.get(this).setFocusedWindow(this);
        }
    }
    

    Now I can connect from the Android Debug Monitor's Hierarchy View and debug my layout.

提交回复
热议问题