Share via


ProfilingManager.RequestProfiling Method

Definition

Request system profiling.

[Android.Runtime.Register("requestProfiling", "(ILandroid/os/Bundle;Ljava/lang/String;Landroid/os/CancellationSignal;Ljava/util/concurrent/Executor;Ljava/util/function/Consumer;)V", "", ApiSince=35)]
public void RequestProfiling(Android.OS.ProfilingType profilingType, Android.OS.Bundle? parameters, string? tag, Android.OS.CancellationSignal? cancellationSignal, Java.Util.Concurrent.IExecutor? executor, Java.Util.Functions.IConsumer? listener);
[<Android.Runtime.Register("requestProfiling", "(ILandroid/os/Bundle;Ljava/lang/String;Landroid/os/CancellationSignal;Ljava/util/concurrent/Executor;Ljava/util/function/Consumer;)V", "", ApiSince=35)>]
member this.RequestProfiling : Android.OS.ProfilingType * Android.OS.Bundle * string * Android.OS.CancellationSignal * Java.Util.Concurrent.IExecutor * Java.Util.Functions.IConsumer -> unit

Parameters

profilingType
ProfilingType

Type of profiling to collect.

parameters
Bundle

Bundle of request related parameters. If the bundle contains any unrecognized parameters, the request will be fail with android.os.ProfilingResult#ERROR_FAILED_INVALID_REQUEST. If the values for the parameters are out of supported range, the closest possible in range value will be chosen. Use of androidx wrappers is recommended over generating this directly.

tag
String

Caller defined data to help identify the output. The first 20 alphanumeric characters, plus dashes, will be lowercased and included in the output filename.

cancellationSignal
CancellationSignal

for caller requested cancellation. Results will be returned if available. If this is null, the requesting app will not be able to stop the collection. The collection will stop after timing out with either the provided configurations or with system defaults

executor
IExecutor

The executor to call back with. Will only be used for the listener provided in this method. If this is null, and no global executor and listener combinations are registered at the time of the request, the request will be dropped.

listener
IConsumer

Listener to be triggered with result. Any global listeners registered via #registerForAllProfilingResults will also be triggered. If this is null, and no global listener and executor combinations are registered at the time of the request, the request will be dropped.

Attributes

Remarks

Request system profiling.

Note: use of this API directly is not recommended for most use cases. Consider using the higher level wrappers provided by AndroidX that will construct the request correctly, supporting available options with simplified request parameters.

Both a listener and an executor must be set at the time of the request for the request to be considered for fulfillment. Listener/executor pairs can be set in this method, with #registerForAllProfilingResults, or both. The listener and executor must be set together, in the same call. If no listener and executor combination is set, the request will be discarded and no callback will be received.

Requests will be rate limited and are not guaranteed to be filled.

There might be a delay before profiling begins. For continuous profiling types (system tracing, stack sampling, and heap profiling), we recommend starting the collection early and stopping it with cancellationSignal immediately after the area of interest to ensure that the section you want profiled is captured. For heap dumps, we recommend testing locally to ensure that the heap dump is collected at the proper time.

Java documentation for android.os.ProfilingManager.requestProfiling(int, android.os.Bundle, java.lang.String, android.os.CancellationSignal, java.util.concurrent.Executor, java.util.function.Consumer<android.os.ProfilingResult>).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to