-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathIComponentCallbacks2.xml
More file actions
166 lines (166 loc) Β· 11.3 KB
/
IComponentCallbacks2.xml
File metadata and controls
166 lines (166 loc) Β· 11.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<Type Name="IComponentCallbacks2" FullName="Android.Content.IComponentCallbacks2">
<TypeSignature Language="C#" Value="public interface IComponentCallbacks2 : Android.Content.IComponentCallbacks, IDisposable, Java.Interop.IJavaPeerable" />
<TypeSignature Language="ILAsm" Value=".class public interface auto ansi abstract beforefieldinit IComponentCallbacks2 implements class Android.Content.IComponentCallbacks, class Android.Runtime.IJavaObject, class Java.Interop.IJavaPeerable, class System.IDisposable" />
<TypeSignature Language="DocId" Value="T:Android.Content.IComponentCallbacks2" />
<TypeSignature Language="F#" Value="type IComponentCallbacks2 = interface
 interface IComponentCallbacks
 interface IJavaObject
 interface IDisposable
 interface IJavaPeerable" />
<AssemblyInfo>
<AssemblyName>Mono.Android</AssemblyName>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Interfaces>
<Interface>
<InterfaceName>Android.Content.IComponentCallbacks</InterfaceName>
</Interface>
<Interface>
<InterfaceName>Android.Runtime.IJavaObject</InterfaceName>
</Interface>
<Interface>
<InterfaceName>Java.Interop.IJavaPeerable</InterfaceName>
</Interface>
<Interface>
<InterfaceName>System.IDisposable</InterfaceName>
</Interface>
</Interfaces>
<Attributes>
<Attribute>
<AttributeName Language="C#">[Android.Runtime.Register("android/content/ComponentCallbacks2", "", "Android.Content.IComponentCallbacks2Invoker")]</AttributeName>
<AttributeName Language="F#">[<Android.Runtime.Register("android/content/ComponentCallbacks2", "", "Android.Content.IComponentCallbacks2Invoker")>]</AttributeName>
</Attribute>
</Attributes>
<Docs since="14">
<summary>Extended <c>ComponentCallbacks</c> interface with a new callback for
finer-grained memory management.</summary>
<remarks>
<para>Extended <c>ComponentCallbacks</c> interface with a new callback for
finer-grained memory management. This interface is available in all application components
(<c>android.app.Activity</c>, <c>android.app.Service</c>,
<c>ContentProvider</c>, and <c>android.app.Application</c>).</para>
<para>You should implement <c>#onTrimMemory</c> to incrementally release memory based on current
system constraints. Using this callback to release your resources helps provide a more
responsive system overall, but also directly benefits the user experience for
your app by allowing the system to keep your process alive longer. That is,
if you <em>don't</em> trim your resources based on memory levels defined by this callback,
the system is more likely to kill your process while it is cached in the least-recently used
(LRU) list, thus requiring your app to restart and restore all state when the user returns to it.</para>
<para>The values provided by <c>#onTrimMemory</c> do not represent a single linear progression of
memory limits, but provide you different types of clues about memory availability:</para>
<para><ul>
<li>When your app is running:
<ol>
<li><c>#TRIM_MEMORY_RUNNING_MODERATE</c><br>The device is beginning to run low on memory.
Your app is running and not killable.
<li><c>#TRIM_MEMORY_RUNNING_LOW</c><br>The device is running much lower on memory.
Your app is running and not killable, but please release unused resources to improve system
performance (which directly impacts your app's performance).
<li><c>#TRIM_MEMORY_RUNNING_CRITICAL</c><br>The device is running extremely low on memory.
Your app is not yet considered a killable process, but the system will begin killing
background processes if apps do not release resources, so you should release non-critical
resources now to prevent performance degradation.
</ol>
</li>
<li>When your app's visibility changes:
<ol>
<li><c>#TRIM_MEMORY_UI_HIDDEN</c><br>Your app's UI is no longer visible, so this is a good
time to release large resources that are used only by your UI.
</ol>
</li>
<li>When your app's process resides in the background LRU list:
<ol>
<li><c>#TRIM_MEMORY_BACKGROUND</c><br>The system is running low on memory and your process is
near the beginning of the LRU list. Although your app process is not at a high risk of being
killed, the system may already be killing processes in the LRU list, so you should release
resources that are easy to recover so your process will remain in the list and resume
quickly when the user returns to your app.
<li><c>#TRIM_MEMORY_MODERATE</c><br>The system is running low on memory and your process is
near the middle of the LRU list. If the system becomes further constrained for memory, there's a
chance your process will be killed.
<li><c>#TRIM_MEMORY_COMPLETE</c><br>The system is running low on memory and your process is
one of the first to be killed if the system does not recover memory now. You should release
absolutely everything that's not critical to resuming your app state.</para>
<para>To support API levels lower than 14, you can use the <c>#onLowMemory</c> method as a
fallback that's roughly equivalent to the <c>ComponentCallbacks2#TRIM_MEMORY_COMPLETE</c> level.
</li>
</ol></para>
<para><strong>Note:</strong> When the system begins
killing processes in the LRU list, although it primarily works bottom-up, it does give some
consideration to which processes are consuming more memory and will thus provide more gains in
memory if killed. So the less memory you consume while in the LRU list overall, the better
your chances are to remain in the list and be able to quickly resume.</para>
<para></li>
</ul></para>
<para>More information about the different stages of a process lifecycle (such as what it means
to be placed in the background LRU list) is provided in the <see href="https://developer.android.com/guide/components/processes-and-threads.html#Lifecycle">Processes and Threads</see>
document.</para>
<para>
<format type="text/html">
<a href="https://developer.android.com/reference/android/content/ComponentCallbacks2" title="Reference documentation">Java documentation for <code>android.content.ComponentCallbacks2</code>.</a>
</format>
</para>
<para>
Portions of this page are modifications based on work created and shared by the
<format type="text/html"><a href="https://developers.google.com/terms/site-policies" title="Android Open Source Project">Android Open Source Project</a></format>
and used according to terms described in the
<format type="text/html"><a href="https://creativecommons.org/licenses/by/2.5/" title="Creative Commons 2.5 Attribution License">Creative Commons 2.5 Attribution License.</a></format></para>
</remarks>
<since version="Added in API level 14" />
</Docs>
<Members>
<Member MemberName="OnTrimMemory">
<MemberSignature Language="C#" Value="public void OnTrimMemory (Android.Content.TrimMemory level);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void OnTrimMemory(valuetype Android.Content.TrimMemory level) cil managed" />
<MemberSignature Language="DocId" Value="M:Android.Content.IComponentCallbacks2.OnTrimMemory(Android.Content.TrimMemory)" />
<MemberSignature Language="F#" Value="abstract member OnTrimMemory : Android.Content.TrimMemory -> unit" Usage="iComponentCallbacks2.OnTrimMemory level" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Mono.Android</AssemblyName>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName Language="C#">[Android.Runtime.Register("onTrimMemory", "(I)V", "GetOnTrimMemory_IHandler:Android.Content.IComponentCallbacks2Invoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]</AttributeName>
<AttributeName Language="F#">[<Android.Runtime.Register("onTrimMemory", "(I)V", "GetOnTrimMemory_IHandler:Android.Content.IComponentCallbacks2Invoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="level" Type="Android.Content.TrimMemory">
<Attributes>
<Attribute>
<AttributeName Language="C#">[Android.Runtime.GeneratedEnum]</AttributeName>
<AttributeName Language="F#">[<Android.Runtime.GeneratedEnum>]</AttributeName>
</Attribute>
</Attributes>
</Parameter>
</Parameters>
<Docs>
<param name="level">The context of the trim, giving a hint of the amount of
trimming the application may like to perform.</param>
<summary>Called when the operating system has determined that it is a good
time for a process to trim unneeded memory from its process.</summary>
<remarks>
<para>Called when the operating system has determined that it is a good
time for a process to trim unneeded memory from its process.</para>
<para>You should never compare to exact values of the level, since new
intermediate values may be added -- you will typically want to compare if
the value is greater or equal to a level you are interested in.</para>
<para>To retrieve the processes current trim level at any point, you can
use <c>android.app.ActivityManager#getMyMemoryState
ActivityManager.getMyMemoryState(RunningAppProcessInfo)</c>.</para>
<para>
<format type="text/html">
<a href="https://developer.android.com/reference/android/content/ComponentCallbacks2#onTrimMemory(int)" title="Reference documentation">Java documentation for <code>android.content.ComponentCallbacks2.onTrimMemory(int)</code>.</a>
</format>
</para>
<para>
Portions of this page are modifications based on work created and shared by the
<format type="text/html"><a href="https://developers.google.com/terms/site-policies" title="Android Open Source Project">Android Open Source Project</a></format>
and used according to terms described in the
<format type="text/html"><a href="https://creativecommons.org/licenses/by/2.5/" title="Creative Commons 2.5 Attribution License">Creative Commons 2.5 Attribution License.</a></format></para>
</remarks>
<since version="Added in API level 14" />
</Docs>
</Member>
</Members>
</Type>