public class

ViewDebug

extends Object
java.lang.Object
   ↳ android.view.ViewDebug

Class Overview

Various debugging/tracing tools related to View and the view hierarchy.

Summary

Nested Classes
@interface ViewDebug.CapturedViewProperty This annotation can be used to mark fields and methods to be dumped when the view is captured. 
@interface ViewDebug.ExportedProperty This annotation can be used to mark fields and methods to be dumped by the view server. 
@interface ViewDebug.FlagToString Defines a mapping from an flag to a String. 
enum ViewDebug.HierarchyTraceType Defines the type of hierarhcy trace to output to the hierarchy traces file. 
@interface ViewDebug.IntToString Defines a mapping from an int value to a String. 
enum ViewDebug.RecyclerTraceType Defines the type of recycler trace to output to the recycler traces file. 
Constants
boolean TRACE_HIERARCHY Enables or disables view hierarchy tracing.
boolean TRACE_RECYCLER Enables or disables view recycler tracing.
Public Constructors
ViewDebug()
Public Methods
static void dumpCapturedView(String tag, Object view)
Dump view info for id based instrument test generation (and possibly further data analysis).
static void startHierarchyTracing(String prefix, View view)
Starts tracing the view hierarchy of the specified view.
static void startRecyclerTracing(String prefix, View view)
Starts tracing the view recycler of the specified view.
static void stopHierarchyTracing()
Stops the current view hierarchy tracing.
static void stopRecyclerTracing()
Stops the current view recycer tracing.
static void trace(View view, ViewDebug.RecyclerTraceType type, int... parameters)
Outputs a trace to the currently opened recycler traces.
static void trace(View view, ViewDebug.HierarchyTraceType type)
Outputs a trace to the currently opened traces file.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final boolean TRACE_HIERARCHY

Since: API Level 1

Enables or disables view hierarchy tracing. Any invoker of trace(View, android.view.ViewDebug.HierarchyTraceType) should first check that this value is set to true as not to affect performance.

Constant Value: false

public static final boolean TRACE_RECYCLER

Since: API Level 1

Enables or disables view recycler tracing. Any invoker of trace(View, android.view.ViewDebug.RecyclerTraceType, int[]) should first check that this value is set to true as not to affect performance.

Constant Value: false

Public Constructors

public ViewDebug ()

Since: API Level 1

Public Methods

public static void dumpCapturedView (String tag, Object view)

Since: API Level 3

Dump view info for id based instrument test generation (and possibly further data analysis). The results are dumped to the log.

Parameters
tag for log
view for dump

public static void startHierarchyTracing (String prefix, View view)

Since: API Level 1

Starts tracing the view hierarchy of the specified view. The trace is identified by a prefix, used to build the traces files names: /EXTERNAL/view-hierarchy/PREFIX.traces and /EXTERNAL/view-hierarchy/PREFIX.tree. Only one view hierarchy can be traced at the same time. After calling this method, any other invocation will result in a IllegalStateException unless stopHierarchyTracing() is invoked before. Calling this method creates the file /EXTERNAL/view-hierarchy/PREFIX.traces containing all the traces (or method calls) relative to the specified view's hierarchy. This method will return immediately if TRACE_HIERARCHY is false.

Parameters
prefix the traces files name prefix
view the view whose hierarchy must be traced

public static void startRecyclerTracing (String prefix, View view)

Since: API Level 1

Starts tracing the view recycler of the specified view. The trace is identified by a prefix, used to build the traces files names: /EXTERNAL/view-recycler/PREFIX.traces and /EXTERNAL/view-recycler/PREFIX.recycler. Only one view recycler can be traced at the same time. After calling this method, any other invocation will result in a IllegalStateException unless stopRecyclerTracing() is invoked before. Traces files are created only after stopRecyclerTracing() is invoked. This method will return immediately if TRACE_RECYCLER is false.

Parameters
prefix the traces files name prefix
view the view whose recycler must be traced

public static void stopHierarchyTracing ()

Since: API Level 1

Stops the current view hierarchy tracing. This method closes the file /EXTERNAL/view-hierarchy/PREFIX.traces. Calling this method creates the file /EXTERNAL/view-hierarchy/PREFIX.tree containing the view hierarchy of the view supplied to startHierarchyTracing(String, View). This method will return immediately if TRACE_HIERARCHY is false.

public static void stopRecyclerTracing ()

Since: API Level 1

Stops the current view recycer tracing. Calling this method creates the file /EXTERNAL/view-recycler/PREFIX.traces containing all the traces (or method calls) relative to the specified view's recycler. Calling this method creates the file /EXTERNAL/view-recycler/PREFIX.recycler containing all of the views used by the recycler of the view supplied to startRecyclerTracing(String, View). This method will return immediately if TRACE_RECYCLER is false.

public static void trace (View view, ViewDebug.RecyclerTraceType type, int... parameters)

Since: API Level 1

Outputs a trace to the currently opened recycler traces. The trace records the type of recycler action performed on the supplied view as well as a number of parameters.

Parameters
view the view to trace
type the type of the trace
parameters parameters depending on the type of the trace

public static void trace (View view, ViewDebug.HierarchyTraceType type)

Since: API Level 1

Outputs a trace to the currently opened traces file. The trace contains the class name and instance's hashcode of the specified view as well as the supplied trace type.

Parameters
view the view to trace
type the type of the trace