The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.content; |
| 18 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 19 | import android.annotation.IntDef; |
| 20 | import android.annotation.NonNull; |
| 21 | import android.annotation.Nullable; |
| 22 | import android.annotation.StringDef; |
Jinsuk Kim | 66d1eb2 | 2014-06-06 16:12:18 +0900 | [diff] [blame] | 23 | import android.annotation.SystemApi; |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 24 | import android.content.pm.ApplicationInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | import android.content.pm.PackageManager; |
| 26 | import android.content.res.AssetManager; |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 27 | import android.content.res.Configuration; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | import android.content.res.Resources; |
| 29 | import android.content.res.TypedArray; |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 30 | import android.database.DatabaseErrorHandler; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | import android.database.sqlite.SQLiteDatabase; |
| 32 | import android.database.sqlite.SQLiteDatabase.CursorFactory; |
| 33 | import android.graphics.Bitmap; |
| 34 | import android.graphics.drawable.Drawable; |
Adam Powell | ac695c6 | 2010-07-20 18:19:27 -0700 | [diff] [blame] | 35 | import android.media.MediaScannerConnection.OnScanCompletedListener; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | import android.net.Uri; |
| 37 | import android.os.Bundle; |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 38 | import android.os.Environment; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | import android.os.Handler; |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 40 | import android.os.IBinder; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | import android.os.Looper; |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 42 | import android.os.StatFs; |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 43 | import android.os.UserHandle; |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 44 | import android.os.UserManager; |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 45 | import android.provider.MediaStore; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 46 | import android.util.AttributeSet; |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 47 | import android.view.DisplayAdjustments; |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 48 | import android.view.Display; |
Jon Miranda | 836c0a8 | 2014-08-11 12:32:26 -0700 | [diff] [blame] | 49 | import android.view.ViewDebug; |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 50 | import android.view.WindowManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | |
| 52 | import java.io.File; |
| 53 | import java.io.FileInputStream; |
| 54 | import java.io.FileNotFoundException; |
| 55 | import java.io.FileOutputStream; |
| 56 | import java.io.IOException; |
| 57 | import java.io.InputStream; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 58 | import java.lang.annotation.Retention; |
| 59 | import java.lang.annotation.RetentionPolicy; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 60 | |
| 61 | /** |
| 62 | * Interface to global information about an application environment. This is |
| 63 | * an abstract class whose implementation is provided by |
| 64 | * the Android system. It |
| 65 | * allows access to application-specific resources and classes, as well as |
| 66 | * up-calls for application-level operations such as launching activities, |
| 67 | * broadcasting and receiving intents, etc. |
| 68 | */ |
| 69 | public abstract class Context { |
| 70 | /** |
| 71 | * File creation mode: the default mode, where the created file can only |
| 72 | * be accessed by the calling application (or all applications sharing the |
| 73 | * same user ID). |
| 74 | * @see #MODE_WORLD_READABLE |
| 75 | * @see #MODE_WORLD_WRITEABLE |
| 76 | */ |
| 77 | public static final int MODE_PRIVATE = 0x0000; |
| 78 | /** |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 79 | * @deprecated Creating world-readable files is very dangerous, and likely |
| 80 | * to cause security holes in applications. It is strongly discouraged; |
| 81 | * instead, applications should use more formal mechanism for interactions |
| 82 | * such as {@link ContentProvider}, {@link BroadcastReceiver}, and |
| 83 | * {@link android.app.Service}. There are no guarantees that this |
| 84 | * access mode will remain on a file, such as when it goes through a |
| 85 | * backup and restore. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 86 | * File creation mode: allow all other applications to have read access |
| 87 | * to the created file. |
| 88 | * @see #MODE_PRIVATE |
| 89 | * @see #MODE_WORLD_WRITEABLE |
| 90 | */ |
Dianne Hackborn | 556b09e | 2012-09-23 17:46:53 -0700 | [diff] [blame] | 91 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 92 | public static final int MODE_WORLD_READABLE = 0x0001; |
| 93 | /** |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 94 | * @deprecated Creating world-writable files is very dangerous, and likely |
| 95 | * to cause security holes in applications. It is strongly discouraged; |
| 96 | * instead, applications should use more formal mechanism for interactions |
| 97 | * such as {@link ContentProvider}, {@link BroadcastReceiver}, and |
| 98 | * {@link android.app.Service}. There are no guarantees that this |
| 99 | * access mode will remain on a file, such as when it goes through a |
| 100 | * backup and restore. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 101 | * File creation mode: allow all other applications to have write access |
| 102 | * to the created file. |
| 103 | * @see #MODE_PRIVATE |
| 104 | * @see #MODE_WORLD_READABLE |
| 105 | */ |
Dianne Hackborn | 556b09e | 2012-09-23 17:46:53 -0700 | [diff] [blame] | 106 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 107 | public static final int MODE_WORLD_WRITEABLE = 0x0002; |
| 108 | /** |
| 109 | * File creation mode: for use with {@link #openFileOutput}, if the file |
| 110 | * already exists then write data to the end of the existing file |
| 111 | * instead of erasing it. |
| 112 | * @see #openFileOutput |
| 113 | */ |
| 114 | public static final int MODE_APPEND = 0x8000; |
| 115 | |
| 116 | /** |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 117 | * SharedPreference loading flag: when set, the file on disk will |
| 118 | * be checked for modification even if the shared preferences |
| 119 | * instance is already loaded in this process. This behavior is |
| 120 | * sometimes desired in cases where the application has multiple |
| 121 | * processes, all writing to the same SharedPreferences file. |
| 122 | * Generally there are better forms of communication between |
| 123 | * processes, though. |
| 124 | * |
| 125 | * <p>This was the legacy (but undocumented) behavior in and |
| 126 | * before Gingerbread (Android 2.3) and this flag is implied when |
| 127 | * targetting such releases. For applications targetting SDK |
| 128 | * versions <em>greater than</em> Android 2.3, this flag must be |
| 129 | * explicitly set if desired. |
| 130 | * |
| 131 | * @see #getSharedPreferences |
| 132 | */ |
| 133 | public static final int MODE_MULTI_PROCESS = 0x0004; |
| 134 | |
| 135 | /** |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 136 | * Database open flag: when set, the database is opened with write-ahead |
| 137 | * logging enabled by default. |
| 138 | * |
| 139 | * @see #openOrCreateDatabase(String, int, CursorFactory) |
| 140 | * @see #openOrCreateDatabase(String, int, CursorFactory, DatabaseErrorHandler) |
| 141 | * @see SQLiteDatabase#enableWriteAheadLogging |
| 142 | */ |
| 143 | public static final int MODE_ENABLE_WRITE_AHEAD_LOGGING = 0x0008; |
| 144 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 145 | /** @hide */ |
| 146 | @IntDef(flag = true, |
| 147 | value = { |
| 148 | BIND_AUTO_CREATE, |
| 149 | BIND_AUTO_CREATE, |
| 150 | BIND_DEBUG_UNBIND, |
| 151 | BIND_NOT_FOREGROUND, |
| 152 | BIND_ABOVE_CLIENT, |
| 153 | BIND_ALLOW_OOM_MANAGEMENT, |
| 154 | BIND_WAIVE_PRIORITY |
| 155 | }) |
| 156 | @Retention(RetentionPolicy.SOURCE) |
| 157 | public @interface BindServiceFlags {} |
| 158 | |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 159 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 160 | * Flag for {@link #bindService}: automatically create the service as long |
| 161 | * as the binding exists. Note that while this will create the service, |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 162 | * its {@link android.app.Service#onStartCommand} |
| 163 | * method will still only be called due to an |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 164 | * explicit call to {@link #startService}. Even without that, though, |
| 165 | * this still provides you with access to the service object while the |
| 166 | * service is created. |
| 167 | * |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 168 | * <p>Note that prior to {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, |
| 169 | * not supplying this flag would also impact how important the system |
| 170 | * consider's the target service's process to be. When set, the only way |
| 171 | * for it to be raised was by binding from a service in which case it will |
| 172 | * only be important when that activity is in the foreground. Now to |
| 173 | * achieve this behavior you must explicitly supply the new flag |
| 174 | * {@link #BIND_ADJUST_WITH_ACTIVITY}. For compatibility, old applications |
| 175 | * that don't specify {@link #BIND_AUTO_CREATE} will automatically have |
| 176 | * the flags {@link #BIND_WAIVE_PRIORITY} and |
| 177 | * {@link #BIND_ADJUST_WITH_ACTIVITY} set for them in order to achieve |
| 178 | * the same result. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 179 | */ |
| 180 | public static final int BIND_AUTO_CREATE = 0x0001; |
| 181 | |
| 182 | /** |
| 183 | * Flag for {@link #bindService}: include debugging help for mismatched |
| 184 | * calls to unbind. When this flag is set, the callstack of the following |
| 185 | * {@link #unbindService} call is retained, to be printed if a later |
| 186 | * incorrect unbind call is made. Note that doing this requires retaining |
| 187 | * information about the binding that was made for the lifetime of the app, |
| 188 | * resulting in a leak -- this should only be used for debugging. |
| 189 | */ |
| 190 | public static final int BIND_DEBUG_UNBIND = 0x0002; |
| 191 | |
Dianne Hackborn | 09c916b | 2009-12-08 14:50:51 -0800 | [diff] [blame] | 192 | /** |
| 193 | * Flag for {@link #bindService}: don't allow this binding to raise |
| 194 | * the target service's process to the foreground scheduling priority. |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 195 | * It will still be raised to at least the same memory priority |
Dianne Hackborn | 09c916b | 2009-12-08 14:50:51 -0800 | [diff] [blame] | 196 | * as the client (so that its process will not be killable in any |
| 197 | * situation where the client is not killable), but for CPU scheduling |
| 198 | * purposes it may be left in the background. This only has an impact |
| 199 | * in the situation where the binding client is a foreground process |
| 200 | * and the target service is in a background process. |
| 201 | */ |
| 202 | public static final int BIND_NOT_FOREGROUND = 0x0004; |
| 203 | |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 204 | /** |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 205 | * Flag for {@link #bindService}: indicates that the client application |
| 206 | * binding to this service considers the service to be more important than |
| 207 | * the app itself. When set, the platform will try to have the out of |
Dianne Hackborn | b12e135 | 2012-09-26 11:39:20 -0700 | [diff] [blame] | 208 | * memory killer kill the app before it kills the service it is bound to, though |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 209 | * this is not guaranteed to be the case. |
| 210 | */ |
| 211 | public static final int BIND_ABOVE_CLIENT = 0x0008; |
| 212 | |
| 213 | /** |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 214 | * Flag for {@link #bindService}: allow the process hosting the bound |
| 215 | * service to go through its normal memory management. It will be |
| 216 | * treated more like a running service, allowing the system to |
| 217 | * (temporarily) expunge the process if low on memory or for some other |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 218 | * whim it may have, and being more aggressive about making it a candidate |
| 219 | * to be killed (and restarted) if running for a long time. |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 220 | */ |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 221 | public static final int BIND_ALLOW_OOM_MANAGEMENT = 0x0010; |
| 222 | |
| 223 | /** |
| 224 | * Flag for {@link #bindService}: don't impact the scheduling or |
| 225 | * memory management priority of the target service's hosting process. |
| 226 | * Allows the service's process to be managed on the background LRU list |
| 227 | * just like a regular application process in the background. |
| 228 | */ |
| 229 | public static final int BIND_WAIVE_PRIORITY = 0x0020; |
| 230 | |
| 231 | /** |
| 232 | * Flag for {@link #bindService}: this service is very important to |
| 233 | * the client, so should be brought to the foreground process level |
| 234 | * when the client is. Normally a process can only be raised to the |
| 235 | * visibility level by a client, even if that client is in the foreground. |
| 236 | */ |
| 237 | public static final int BIND_IMPORTANT = 0x0040; |
| 238 | |
| 239 | /** |
| 240 | * Flag for {@link #bindService}: If binding from an activity, allow the |
| 241 | * target service's process importance to be raised based on whether the |
| 242 | * activity is visible to the user, regardless whether another flag is |
| 243 | * used to reduce the amount that the client process's overall importance |
| 244 | * is used to impact it. |
| 245 | */ |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 246 | public static final int BIND_ADJUST_WITH_ACTIVITY = 0x0080; |
| 247 | |
| 248 | /** |
Dianne Hackborn | f0f94d1 | 2014-03-17 16:04:21 -0700 | [diff] [blame] | 249 | * @hide Flag for {@link #bindService}: Treat the binding as hosting |
| 250 | * an activity, an unbinding as the activity going in the background. |
| 251 | * That is, when unbinding, the process when empty will go on the activity |
| 252 | * LRU list instead of the regular one, keeping it around more aggressively |
| 253 | * than it otherwise would be. This is intended for use with IMEs to try |
| 254 | * to keep IME processes around for faster keyboard switching. |
| 255 | */ |
| 256 | public static final int BIND_TREAT_LIKE_ACTIVITY = 0x08000000; |
| 257 | |
| 258 | /** |
Dianne Hackborn | b12e135 | 2012-09-26 11:39:20 -0700 | [diff] [blame] | 259 | * @hide An idea that is not yet implemented. |
| 260 | * Flag for {@link #bindService}: If binding from an activity, consider |
| 261 | * this service to be visible like the binding activity is. That is, |
| 262 | * it will be treated as something more important to keep around than |
| 263 | * invisible background activities. This will impact the number of |
| 264 | * recent activities the user can switch between without having them |
| 265 | * restart. There is no guarantee this will be respected, as the system |
| 266 | * tries to balance such requests from one app vs. the importantance of |
| 267 | * keeping other apps around. |
| 268 | */ |
Dianne Hackborn | c823051 | 2013-07-13 21:32:12 -0700 | [diff] [blame] | 269 | public static final int BIND_VISIBLE = 0x10000000; |
| 270 | |
| 271 | /** |
| 272 | * @hide |
| 273 | * Flag for {@link #bindService}: Consider this binding to be causing the target |
| 274 | * process to be showing UI, so it will be do a UI_HIDDEN memory trim when it goes |
| 275 | * away. |
| 276 | */ |
| 277 | public static final int BIND_SHOWING_UI = 0x20000000; |
Dianne Hackborn | b12e135 | 2012-09-26 11:39:20 -0700 | [diff] [blame] | 278 | |
| 279 | /** |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 280 | * Flag for {@link #bindService}: Don't consider the bound service to be |
| 281 | * visible, even if the caller is visible. |
| 282 | * @hide |
| 283 | */ |
| 284 | public static final int BIND_NOT_VISIBLE = 0x40000000; |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 285 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 286 | /** Return an AssetManager instance for your application's package. */ |
| 287 | public abstract AssetManager getAssets(); |
| 288 | |
| 289 | /** Return a Resources instance for your application's package. */ |
| 290 | public abstract Resources getResources(); |
| 291 | |
| 292 | /** Return PackageManager instance to find global package information. */ |
| 293 | public abstract PackageManager getPackageManager(); |
| 294 | |
| 295 | /** Return a ContentResolver instance for your application's package. */ |
| 296 | public abstract ContentResolver getContentResolver(); |
| 297 | |
| 298 | /** |
| 299 | * Return the Looper for the main thread of the current process. This is |
| 300 | * the thread used to dispatch calls to application components (activities, |
| 301 | * services, etc). |
Jeff Brown | f9e989d | 2013-04-04 23:04:03 -0700 | [diff] [blame] | 302 | * <p> |
| 303 | * By definition, this method returns the same result as would be obtained |
| 304 | * by calling {@link Looper#getMainLooper() Looper.getMainLooper()}. |
| 305 | * </p> |
| 306 | * |
| 307 | * @return The main looper. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 308 | */ |
| 309 | public abstract Looper getMainLooper(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 310 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 311 | /** |
| 312 | * Return the context of the single, global Application object of the |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 313 | * current process. This generally should only be used if you need a |
| 314 | * Context whose lifecycle is separate from the current context, that is |
| 315 | * tied to the lifetime of the process rather than the current component. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 316 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 317 | * <p>Consider for example how this interacts with |
Brad Fitzpatrick | 36af794 | 2010-12-08 11:31:07 -0800 | [diff] [blame] | 318 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter)}: |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 319 | * <ul> |
| 320 | * <li> <p>If used from an Activity context, the receiver is being registered |
| 321 | * within that activity. This means that you are expected to unregister |
| 322 | * before the activity is done being destroyed; in fact if you do not do |
| 323 | * so, the framework will clean up your leaked registration as it removes |
| 324 | * the activity and log an error. Thus, if you use the Activity context |
| 325 | * to register a receiver that is static (global to the process, not |
| 326 | * associated with an Activity instance) then that registration will be |
| 327 | * removed on you at whatever point the activity you used is destroyed. |
| 328 | * <li> <p>If used from the Context returned here, the receiver is being |
| 329 | * registered with the global state associated with your application. Thus |
| 330 | * it will never be unregistered for you. This is necessary if the receiver |
| 331 | * is associated with static data, not a particular component. However |
| 332 | * using the ApplicationContext elsewhere can easily lead to serious leaks |
| 333 | * if you forget to unregister, unbind, etc. |
| 334 | * </ul> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 335 | */ |
| 336 | public abstract Context getApplicationContext(); |
| 337 | |
| 338 | /** |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 339 | * Add a new {@link ComponentCallbacks} to the base application of the |
| 340 | * Context, which will be called at the same times as the ComponentCallbacks |
| 341 | * methods of activities and other components are called. Note that you |
| 342 | * <em>must</em> be sure to use {@link #unregisterComponentCallbacks} when |
| 343 | * appropriate in the future; this will not be removed for you. |
Dianne Hackborn | 905577f | 2011-09-07 18:31:28 -0700 | [diff] [blame] | 344 | * |
| 345 | * @param callback The interface to call. This can be either a |
| 346 | * {@link ComponentCallbacks} or {@link ComponentCallbacks2} interface. |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 347 | */ |
| 348 | public void registerComponentCallbacks(ComponentCallbacks callback) { |
| 349 | getApplicationContext().registerComponentCallbacks(callback); |
| 350 | } |
| 351 | |
| 352 | /** |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 353 | * Remove a {@link ComponentCallbacks} object that was previously registered |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 354 | * with {@link #registerComponentCallbacks(ComponentCallbacks)}. |
| 355 | */ |
| 356 | public void unregisterComponentCallbacks(ComponentCallbacks callback) { |
| 357 | getApplicationContext().unregisterComponentCallbacks(callback); |
| 358 | } |
| 359 | |
| 360 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 361 | * Return a localized, styled CharSequence from the application's package's |
| 362 | * default string table. |
| 363 | * |
| 364 | * @param resId Resource id for the CharSequence text |
| 365 | */ |
| 366 | public final CharSequence getText(int resId) { |
| 367 | return getResources().getText(resId); |
| 368 | } |
| 369 | |
| 370 | /** |
| 371 | * Return a localized string from the application's package's |
| 372 | * default string table. |
| 373 | * |
| 374 | * @param resId Resource id for the string |
| 375 | */ |
| 376 | public final String getString(int resId) { |
| 377 | return getResources().getString(resId); |
| 378 | } |
| 379 | |
| 380 | /** |
| 381 | * Return a localized formatted string from the application's package's |
| 382 | * default string table, substituting the format arguments as defined in |
| 383 | * {@link java.util.Formatter} and {@link java.lang.String#format}. |
| 384 | * |
| 385 | * @param resId Resource id for the format string |
| 386 | * @param formatArgs The format arguments that will be used for substitution. |
| 387 | */ |
| 388 | |
| 389 | public final String getString(int resId, Object... formatArgs) { |
| 390 | return getResources().getString(resId, formatArgs); |
| 391 | } |
| 392 | |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 393 | /** |
| 394 | * Return a drawable object associated with a particular resource ID and |
| 395 | * styled for the current theme. |
| 396 | * |
| 397 | * @param id The desired resource identifier, as generated by the aapt |
| 398 | * tool. This integer encodes the package, type, and resource |
| 399 | * entry. The value 0 is an invalid identifier. |
| 400 | * @return Drawable An object that can be used to draw this resource. |
| 401 | */ |
| 402 | public final Drawable getDrawable(int id) { |
| 403 | return getResources().getDrawable(id, getTheme()); |
| 404 | } |
| 405 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 406 | /** |
| 407 | * Set the base theme for this context. Note that this should be called |
| 408 | * before any views are instantiated in the Context (for example before |
| 409 | * calling {@link android.app.Activity#setContentView} or |
| 410 | * {@link android.view.LayoutInflater#inflate}). |
| 411 | * |
| 412 | * @param resid The style resource describing the theme. |
| 413 | */ |
| 414 | public abstract void setTheme(int resid); |
| 415 | |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 416 | /** @hide Needed for some internal implementation... not public because |
| 417 | * you can't assume this actually means anything. */ |
| 418 | public int getThemeResId() { |
| 419 | return 0; |
| 420 | } |
| 421 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 422 | /** |
| 423 | * Return the Theme object associated with this Context. |
| 424 | */ |
Jon Miranda | 836c0a8 | 2014-08-11 12:32:26 -0700 | [diff] [blame] | 425 | @ViewDebug.ExportedProperty(deepExport = true) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 426 | public abstract Resources.Theme getTheme(); |
| 427 | |
| 428 | /** |
| 429 | * Retrieve styled attribute information in this Context's theme. See |
| 430 | * {@link Resources.Theme#obtainStyledAttributes(int[])} |
| 431 | * for more information. |
| 432 | * |
| 433 | * @see Resources.Theme#obtainStyledAttributes(int[]) |
| 434 | */ |
| 435 | public final TypedArray obtainStyledAttributes( |
| 436 | int[] attrs) { |
| 437 | return getTheme().obtainStyledAttributes(attrs); |
| 438 | } |
| 439 | |
| 440 | /** |
| 441 | * Retrieve styled attribute information in this Context's theme. See |
| 442 | * {@link Resources.Theme#obtainStyledAttributes(int, int[])} |
| 443 | * for more information. |
| 444 | * |
| 445 | * @see Resources.Theme#obtainStyledAttributes(int, int[]) |
| 446 | */ |
| 447 | public final TypedArray obtainStyledAttributes( |
| 448 | int resid, int[] attrs) throws Resources.NotFoundException { |
| 449 | return getTheme().obtainStyledAttributes(resid, attrs); |
| 450 | } |
| 451 | |
| 452 | /** |
| 453 | * Retrieve styled attribute information in this Context's theme. See |
| 454 | * {@link Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int)} |
| 455 | * for more information. |
| 456 | * |
| 457 | * @see Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int) |
| 458 | */ |
| 459 | public final TypedArray obtainStyledAttributes( |
| 460 | AttributeSet set, int[] attrs) { |
| 461 | return getTheme().obtainStyledAttributes(set, attrs, 0, 0); |
| 462 | } |
| 463 | |
| 464 | /** |
| 465 | * Retrieve styled attribute information in this Context's theme. See |
| 466 | * {@link Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int)} |
| 467 | * for more information. |
| 468 | * |
| 469 | * @see Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int) |
| 470 | */ |
| 471 | public final TypedArray obtainStyledAttributes( |
| 472 | AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes) { |
| 473 | return getTheme().obtainStyledAttributes( |
| 474 | set, attrs, defStyleAttr, defStyleRes); |
| 475 | } |
| 476 | |
| 477 | /** |
| 478 | * Return a class loader you can use to retrieve classes in this package. |
| 479 | */ |
| 480 | public abstract ClassLoader getClassLoader(); |
| 481 | |
| 482 | /** Return the name of this application's package. */ |
| 483 | public abstract String getPackageName(); |
| 484 | |
Dianne Hackborn | d8e1dbb | 2013-01-17 17:47:37 -0800 | [diff] [blame] | 485 | /** @hide Return the name of the base context this context is derived from. */ |
| 486 | public abstract String getBasePackageName(); |
| 487 | |
Dianne Hackborn | 95d7853 | 2013-09-11 09:51:14 -0700 | [diff] [blame] | 488 | /** @hide Return the package name that should be used for app ops calls from |
| 489 | * this context. This is the same as {@link #getBasePackageName()} except in |
| 490 | * cases where system components are loaded into other app processes, in which |
| 491 | * case this will be the name of the primary package in that process (so that app |
| 492 | * ops uid verification will work with the name). */ |
| 493 | public abstract String getOpPackageName(); |
| 494 | |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 495 | /** Return the full application info for this context's package. */ |
| 496 | public abstract ApplicationInfo getApplicationInfo(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 497 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 498 | /** |
Kenny Root | 3214839 | 2010-01-21 15:40:47 -0800 | [diff] [blame] | 499 | * Return the full path to this context's primary Android package. |
| 500 | * The Android package is a ZIP file which contains the application's |
| 501 | * primary resources. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 502 | * |
| 503 | * <p>Note: this is not generally useful for applications, since they should |
| 504 | * not be directly accessing the file system. |
| 505 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 506 | * @return String Path to the resources. |
| 507 | */ |
| 508 | public abstract String getPackageResourcePath(); |
| 509 | |
| 510 | /** |
Kenny Root | 3214839 | 2010-01-21 15:40:47 -0800 | [diff] [blame] | 511 | * Return the full path to this context's primary Android package. |
| 512 | * The Android package is a ZIP file which contains application's |
| 513 | * primary code and assets. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 514 | * |
| 515 | * <p>Note: this is not generally useful for applications, since they should |
| 516 | * not be directly accessing the file system. |
| 517 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 518 | * @return String Path to the code and assets. |
| 519 | */ |
| 520 | public abstract String getPackageCodePath(); |
| 521 | |
| 522 | /** |
Joe Onorato | 23ecae3 | 2009-06-10 17:07:15 -0700 | [diff] [blame] | 523 | * {@hide} |
| 524 | * Return the full path to the shared prefs file for the given prefs group name. |
| 525 | * |
| 526 | * <p>Note: this is not generally useful for applications, since they should |
| 527 | * not be directly accessing the file system. |
| 528 | */ |
| 529 | public abstract File getSharedPrefsFile(String name); |
| 530 | |
| 531 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 532 | * Retrieve and hold the contents of the preferences file 'name', returning |
| 533 | * a SharedPreferences through which you can retrieve and modify its |
| 534 | * values. Only one instance of the SharedPreferences object is returned |
| 535 | * to any callers for the same name, meaning they will see each other's |
| 536 | * edits as soon as they are made. |
| 537 | * |
| 538 | * @param name Desired preferences file. If a preferences file by this name |
| 539 | * does not exist, it will be created when you retrieve an |
| 540 | * editor (SharedPreferences.edit()) and then commit changes (Editor.commit()). |
| 541 | * @param mode Operating mode. Use 0 or {@link #MODE_PRIVATE} for the |
| 542 | * default operation, {@link #MODE_WORLD_READABLE} |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 543 | * and {@link #MODE_WORLD_WRITEABLE} to control permissions. The bit |
| 544 | * {@link #MODE_MULTI_PROCESS} can also be used if multiple processes |
| 545 | * are mutating the same SharedPreferences file. {@link #MODE_MULTI_PROCESS} |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 546 | * is always on in apps targeting Gingerbread (Android 2.3) and below, and |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 547 | * off by default in later versions. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 548 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 549 | * @return The single {@link SharedPreferences} instance that can be used |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 550 | * to retrieve and modify the preference values. |
| 551 | * |
| 552 | * @see #MODE_PRIVATE |
| 553 | * @see #MODE_WORLD_READABLE |
| 554 | * @see #MODE_WORLD_WRITEABLE |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 555 | * @see #MODE_MULTI_PROCESS |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 556 | */ |
| 557 | public abstract SharedPreferences getSharedPreferences(String name, |
| 558 | int mode); |
| 559 | |
| 560 | /** |
| 561 | * Open a private file associated with this Context's application package |
| 562 | * for reading. |
| 563 | * |
| 564 | * @param name The name of the file to open; can not contain path |
| 565 | * separators. |
| 566 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 567 | * @return The resulting {@link FileInputStream}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 568 | * |
| 569 | * @see #openFileOutput |
| 570 | * @see #fileList |
| 571 | * @see #deleteFile |
| 572 | * @see java.io.FileInputStream#FileInputStream(String) |
| 573 | */ |
| 574 | public abstract FileInputStream openFileInput(String name) |
| 575 | throws FileNotFoundException; |
| 576 | |
| 577 | /** |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 578 | * Open a private file associated with this Context's application package |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 579 | * for writing. Creates the file if it doesn't already exist. |
| 580 | * |
Ricardo Cervera | 90a5f98 | 2014-04-04 10:26:05 -0700 | [diff] [blame] | 581 | * <p>No permissions are required to invoke this method, since it uses internal |
| 582 | * storage. |
| 583 | * |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 584 | * @param name The name of the file to open; can not contain path |
| 585 | * separators. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 586 | * @param mode Operating mode. Use 0 or {@link #MODE_PRIVATE} for the |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 587 | * default operation, {@link #MODE_APPEND} to append to an existing file, |
| 588 | * {@link #MODE_WORLD_READABLE} and {@link #MODE_WORLD_WRITEABLE} to control |
| 589 | * permissions. |
| 590 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 591 | * @return The resulting {@link FileOutputStream}. |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 592 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 593 | * @see #MODE_APPEND |
| 594 | * @see #MODE_PRIVATE |
| 595 | * @see #MODE_WORLD_READABLE |
| 596 | * @see #MODE_WORLD_WRITEABLE |
| 597 | * @see #openFileInput |
| 598 | * @see #fileList |
| 599 | * @see #deleteFile |
| 600 | * @see java.io.FileOutputStream#FileOutputStream(String) |
| 601 | */ |
| 602 | public abstract FileOutputStream openFileOutput(String name, int mode) |
| 603 | throws FileNotFoundException; |
| 604 | |
| 605 | /** |
| 606 | * Delete the given private file associated with this Context's |
| 607 | * application package. |
| 608 | * |
| 609 | * @param name The name of the file to delete; can not contain path |
| 610 | * separators. |
| 611 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 612 | * @return {@code true} if the file was successfully deleted; else |
| 613 | * {@code false}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 614 | * |
| 615 | * @see #openFileInput |
| 616 | * @see #openFileOutput |
| 617 | * @see #fileList |
| 618 | * @see java.io.File#delete() |
| 619 | */ |
| 620 | public abstract boolean deleteFile(String name); |
| 621 | |
| 622 | /** |
| 623 | * Returns the absolute path on the filesystem where a file created with |
| 624 | * {@link #openFileOutput} is stored. |
| 625 | * |
| 626 | * @param name The name of the file for which you would like to get |
| 627 | * its path. |
| 628 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 629 | * @return An absolute path to the given file. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 630 | * |
| 631 | * @see #openFileOutput |
| 632 | * @see #getFilesDir |
| 633 | * @see #getDir |
| 634 | */ |
| 635 | public abstract File getFileStreamPath(String name); |
| 636 | |
| 637 | /** |
| 638 | * Returns the absolute path to the directory on the filesystem where |
| 639 | * files created with {@link #openFileOutput} are stored. |
| 640 | * |
Ricardo Cervera | 90a5f98 | 2014-04-04 10:26:05 -0700 | [diff] [blame] | 641 | * <p>No permissions are required to read or write to the returned path, since this |
| 642 | * path is internal storage. |
| 643 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 644 | * @return The path of the directory holding application files. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 645 | * |
| 646 | * @see #openFileOutput |
| 647 | * @see #getFileStreamPath |
| 648 | * @see #getDir |
| 649 | */ |
| 650 | public abstract File getFilesDir(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 651 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 652 | /** |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 653 | * Returns the absolute path to the directory on the filesystem similar to |
| 654 | * {@link #getFilesDir()}. The difference is that files placed under this |
| 655 | * directory will be excluded from automatic backup to remote storage. See |
| 656 | * {@link android.app.backup.BackupAgent BackupAgent} for a full discussion |
| 657 | * of the automatic backup mechanism in Android. |
| 658 | * |
| 659 | * <p>No permissions are required to read or write to the returned path, since this |
| 660 | * path is internal storage. |
| 661 | * |
| 662 | * @return The path of the directory holding application files that will not be |
| 663 | * automatically backed up to remote storage. |
| 664 | * |
| 665 | * @see #openFileOutput |
| 666 | * @see #getFileStreamPath |
| 667 | * @see #getDir |
| 668 | * @see android.app.backup.BackupAgent |
| 669 | */ |
| 670 | public abstract File getNoBackupFilesDir(); |
| 671 | |
| 672 | /** |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 673 | * Returns the absolute path to the directory on the primary external filesystem |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 674 | * (that is somewhere on {@link android.os.Environment#getExternalStorageDirectory() |
Dianne Hackborn | acaf028 | 2010-03-30 14:39:35 -0700 | [diff] [blame] | 675 | * Environment.getExternalStorageDirectory()}) where the application can |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 676 | * place persistent files it owns. These files are internal to the |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 677 | * applications, and not typically visible to the user as media. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 678 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 679 | * <p>This is like {@link #getFilesDir()} in that these |
| 680 | * files will be deleted when the application is uninstalled, however there |
| 681 | * are some important differences: |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 682 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 683 | * <ul> |
| 684 | * <li>External files are not always available: they will disappear if the |
| 685 | * user mounts the external storage on a computer or removes it. See the |
| 686 | * APIs on {@link android.os.Environment} for information in the storage state. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 687 | * <li>There is no security enforced with these files. For example, any application |
| 688 | * holding {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 689 | * these files. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 690 | * </ul> |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 691 | * |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 692 | * <p>Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions |
| 693 | * are required to read or write to the returned path; it's always |
| 694 | * accessible to the calling app. This only applies to paths generated for |
| 695 | * package name of the calling application. To access paths belonging |
| 696 | * to other packages, {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} |
| 697 | * and/or {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} are required. |
| 698 | * |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 699 | * <p>On devices with multiple users (as described by {@link UserManager}), |
| 700 | * each user has their own isolated external storage. Applications only |
| 701 | * have access to the external storage for the user they're running as.</p> |
| 702 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 703 | * <p>Here is an example of typical code to manipulate a file in |
| 704 | * an application's private storage:</p> |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 705 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 706 | * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java |
| 707 | * private_file} |
| 708 | * |
Dianne Hackborn | acaf028 | 2010-03-30 14:39:35 -0700 | [diff] [blame] | 709 | * <p>If you supply a non-null <var>type</var> to this function, the returned |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 710 | * file will be a path to a sub-directory of the given type. Though these files |
| 711 | * are not automatically scanned by the media scanner, you can explicitly |
| 712 | * add them to the media database with |
| 713 | * {@link android.media.MediaScannerConnection#scanFile(Context, String[], String[], |
Ray Chen | b7c8c76 | 2010-03-30 17:21:39 -0700 | [diff] [blame] | 714 | * OnScanCompletedListener) MediaScannerConnection.scanFile}. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 715 | * Note that this is not the same as |
| 716 | * {@link android.os.Environment#getExternalStoragePublicDirectory |
| 717 | * Environment.getExternalStoragePublicDirectory()}, which provides |
| 718 | * directories of media shared by all applications. The |
| 719 | * directories returned here are |
Dianne Hackborn | acaf028 | 2010-03-30 14:39:35 -0700 | [diff] [blame] | 720 | * owned by the application, and their contents will be removed when the |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 721 | * application is uninstalled. Unlike |
| 722 | * {@link android.os.Environment#getExternalStoragePublicDirectory |
| 723 | * Environment.getExternalStoragePublicDirectory()}, the directory |
| 724 | * returned here will be automatically created for you. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 725 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 726 | * <p>Here is an example of typical code to manipulate a picture in |
| 727 | * an application's private storage and add it to the media database:</p> |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 728 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 729 | * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java |
| 730 | * private_picture} |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 731 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 732 | * @param type The type of files directory to return. May be null for |
| 733 | * the root of the files directory or one of |
| 734 | * the following Environment constants for a subdirectory: |
| 735 | * {@link android.os.Environment#DIRECTORY_MUSIC}, |
| 736 | * {@link android.os.Environment#DIRECTORY_PODCASTS}, |
| 737 | * {@link android.os.Environment#DIRECTORY_RINGTONES}, |
| 738 | * {@link android.os.Environment#DIRECTORY_ALARMS}, |
| 739 | * {@link android.os.Environment#DIRECTORY_NOTIFICATIONS}, |
| 740 | * {@link android.os.Environment#DIRECTORY_PICTURES}, or |
| 741 | * {@link android.os.Environment#DIRECTORY_MOVIES}. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 742 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 743 | * @return The path of the directory holding application files |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 744 | * on external storage. Returns null if external storage is not currently |
| 745 | * mounted so it could not ensure the path exists; you will need to call |
| 746 | * this method again when it is available. |
| 747 | * |
| 748 | * @see #getFilesDir |
Dianne Hackborn | acaf028 | 2010-03-30 14:39:35 -0700 | [diff] [blame] | 749 | * @see android.os.Environment#getExternalStoragePublicDirectory |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 750 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 751 | @Nullable |
| 752 | public abstract File getExternalFilesDir(@Nullable String type); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 753 | |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 754 | /** |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 755 | * Returns absolute paths to application-specific directories on all |
| 756 | * external storage devices where the application can place persistent files |
| 757 | * it owns. These files are internal to the application, and not typically |
| 758 | * visible to the user as media. |
| 759 | * <p> |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 760 | * This is like {@link #getFilesDir()} in that these files will be deleted when |
| 761 | * the application is uninstalled, however there are some important differences: |
| 762 | * <ul> |
| 763 | * <li>External files are not always available: they will disappear if the |
| 764 | * user mounts the external storage on a computer or removes it. |
| 765 | * <li>There is no security enforced with these files. |
| 766 | * </ul> |
| 767 | * <p> |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 768 | * External storage devices returned here are considered a permanent part of |
| 769 | * the device, including both emulated external storage and physical media |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 770 | * slots, such as SD cards in a battery compartment. The returned paths do |
| 771 | * not include transient devices, such as USB flash drives. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 772 | * <p> |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 773 | * An application may store data on any or all of the returned devices. For |
| 774 | * example, an app may choose to store large files on the device with the |
| 775 | * most available space, as measured by {@link StatFs}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 776 | * <p> |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 777 | * No permissions are required to read or write to the returned paths; they |
| 778 | * are always accessible to the calling app. Write access outside of these |
| 779 | * paths on secondary external storage devices is not available. |
| 780 | * <p> |
| 781 | * The first path returned is the same as {@link #getExternalFilesDir(String)}. |
| 782 | * Returned paths may be {@code null} if a storage device is unavailable. |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 783 | * |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 784 | * @see #getExternalFilesDir(String) |
Jeff Sharkey | 4ca728c | 2014-01-10 16:27:19 -0800 | [diff] [blame] | 785 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 786 | */ |
| 787 | public abstract File[] getExternalFilesDirs(String type); |
| 788 | |
| 789 | /** |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 790 | * Return the primary external storage directory where this application's OBB |
| 791 | * files (if there are any) can be found. Note if the application does not have |
| 792 | * any OBB files, this directory may not exist. |
| 793 | * <p> |
| 794 | * This is like {@link #getFilesDir()} in that these files will be deleted when |
| 795 | * the application is uninstalled, however there are some important differences: |
| 796 | * <ul> |
| 797 | * <li>External files are not always available: they will disappear if the |
| 798 | * user mounts the external storage on a computer or removes it. |
| 799 | * <li>There is no security enforced with these files. For example, any application |
| 800 | * holding {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 801 | * these files. |
| 802 | * </ul> |
| 803 | * <p> |
| 804 | * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions |
| 805 | * are required to read or write to the returned path; it's always |
| 806 | * accessible to the calling app. This only applies to paths generated for |
| 807 | * package name of the calling application. To access paths belonging |
| 808 | * to other packages, {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} |
| 809 | * and/or {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} are required. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 810 | * <p> |
| 811 | * On devices with multiple users (as described by {@link UserManager}), |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 812 | * multiple users may share the same OBB storage location. Applications |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 813 | * should ensure that multiple instances running under different users don't |
| 814 | * interfere with each other. |
Dianne Hackborn | 805fd7e | 2011-01-16 18:30:29 -0800 | [diff] [blame] | 815 | */ |
| 816 | public abstract File getObbDir(); |
| 817 | |
| 818 | /** |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 819 | * Returns absolute paths to application-specific directories on all |
| 820 | * external storage devices where the application's OBB files (if there are |
| 821 | * any) can be found. Note if the application does not have any OBB files, |
| 822 | * these directories may not exist. |
| 823 | * <p> |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 824 | * This is like {@link #getFilesDir()} in that these files will be deleted when |
| 825 | * the application is uninstalled, however there are some important differences: |
| 826 | * <ul> |
| 827 | * <li>External files are not always available: they will disappear if the |
| 828 | * user mounts the external storage on a computer or removes it. |
| 829 | * <li>There is no security enforced with these files. |
| 830 | * </ul> |
| 831 | * <p> |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 832 | * External storage devices returned here are considered a permanent part of |
| 833 | * the device, including both emulated external storage and physical media |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 834 | * slots, such as SD cards in a battery compartment. The returned paths do |
| 835 | * not include transient devices, such as USB flash drives. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 836 | * <p> |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 837 | * An application may store data on any or all of the returned devices. For |
| 838 | * example, an app may choose to store large files on the device with the |
| 839 | * most available space, as measured by {@link StatFs}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 840 | * <p> |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 841 | * No permissions are required to read or write to the returned paths; they |
| 842 | * are always accessible to the calling app. Write access outside of these |
| 843 | * paths on secondary external storage devices is not available. |
| 844 | * <p> |
| 845 | * The first path returned is the same as {@link #getObbDir()}. |
| 846 | * Returned paths may be {@code null} if a storage device is unavailable. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 847 | * |
| 848 | * @see #getObbDir() |
Jeff Sharkey | 4ca728c | 2014-01-10 16:27:19 -0800 | [diff] [blame] | 849 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 850 | */ |
| 851 | public abstract File[] getObbDirs(); |
| 852 | |
| 853 | /** |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 854 | * Returns the absolute path to the application specific cache directory |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 855 | * on the filesystem. These files will be ones that get deleted first when the |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 856 | * device runs low on storage. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 857 | * There is no guarantee when these files will be deleted. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 858 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 859 | * <strong>Note: you should not <em>rely</em> on the system deleting these |
| 860 | * files for you; you should always have a reasonable maximum, such as 1 MB, |
| 861 | * for the amount of space you consume with cache files, and prune those |
| 862 | * files when exceeding that space.</strong> |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 863 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 864 | * @return The path of the directory holding application cache files. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 865 | * |
| 866 | * @see #openFileOutput |
| 867 | * @see #getFileStreamPath |
| 868 | * @see #getDir |
| 869 | */ |
| 870 | public abstract File getCacheDir(); |
| 871 | |
| 872 | /** |
Jeff Sharkey | 4ed745d | 2014-07-15 20:39:15 -0700 | [diff] [blame] | 873 | * Returns the absolute path to the application specific cache directory on |
| 874 | * the filesystem designed for storing cached code. The system will delete |
| 875 | * any files stored in this location both when your specific application is |
| 876 | * upgraded, and when the entire platform is upgraded. |
| 877 | * <p> |
| 878 | * This location is optimal for storing compiled or optimized code generated |
| 879 | * by your application at runtime. |
| 880 | * <p> |
| 881 | * Apps require no extra permissions to read or write to the returned path, |
| 882 | * since this path lives in their private storage. |
| 883 | * |
| 884 | * @return The path of the directory holding application code cache files. |
| 885 | */ |
| 886 | public abstract File getCodeCacheDir(); |
| 887 | |
| 888 | /** |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 889 | * Returns the absolute path to the directory on the primary external filesystem |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 890 | * (that is somewhere on {@link android.os.Environment#getExternalStorageDirectory() |
| 891 | * Environment.getExternalStorageDirectory()} where the application can |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 892 | * place cache files it owns. These files are internal to the application, and |
| 893 | * not typically visible to the user as media. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 894 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 895 | * <p>This is like {@link #getCacheDir()} in that these |
| 896 | * files will be deleted when the application is uninstalled, however there |
| 897 | * are some important differences: |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 898 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 899 | * <ul> |
Dianne Hackborn | 556b09e | 2012-09-23 17:46:53 -0700 | [diff] [blame] | 900 | * <li>The platform does not always monitor the space available in external |
| 901 | * storage, and thus may not automatically delete these files. Currently |
| 902 | * the only time files here will be deleted by the platform is when running |
| 903 | * on {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} or later and |
| 904 | * {@link android.os.Environment#isExternalStorageEmulated() |
| 905 | * Environment.isExternalStorageEmulated()} returns true. Note that you should |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 906 | * be managing the maximum space you will use for these anyway, just like |
| 907 | * with {@link #getCacheDir()}. |
| 908 | * <li>External files are not always available: they will disappear if the |
| 909 | * user mounts the external storage on a computer or removes it. See the |
| 910 | * APIs on {@link android.os.Environment} for information in the storage state. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 911 | * <li>There is no security enforced with these files. For example, any application |
| 912 | * holding {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 913 | * these files. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 914 | * </ul> |
| 915 | * |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 916 | * <p>Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions |
| 917 | * are required to read or write to the returned path; it's always |
| 918 | * accessible to the calling app. This only applies to paths generated for |
| 919 | * package name of the calling application. To access paths belonging |
| 920 | * to other packages, {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} |
| 921 | * and/or {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} are required. |
| 922 | * |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 923 | * <p>On devices with multiple users (as described by {@link UserManager}), |
| 924 | * each user has their own isolated external storage. Applications only |
| 925 | * have access to the external storage for the user they're running as.</p> |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 926 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 927 | * @return The path of the directory holding application cache files |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 928 | * on external storage. Returns null if external storage is not currently |
| 929 | * mounted so it could not ensure the path exists; you will need to call |
| 930 | * this method again when it is available. |
| 931 | * |
| 932 | * @see #getCacheDir |
| 933 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 934 | @Nullable |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 935 | public abstract File getExternalCacheDir(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 936 | |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 937 | /** |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 938 | * Returns absolute paths to application-specific directories on all |
| 939 | * external storage devices where the application can place cache files it |
| 940 | * owns. These files are internal to the application, and not typically |
| 941 | * visible to the user as media. |
| 942 | * <p> |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 943 | * This is like {@link #getCacheDir()} in that these files will be deleted when |
| 944 | * the application is uninstalled, however there are some important differences: |
| 945 | * <ul> |
| 946 | * <li>External files are not always available: they will disappear if the |
| 947 | * user mounts the external storage on a computer or removes it. |
| 948 | * <li>There is no security enforced with these files. |
| 949 | * </ul> |
| 950 | * <p> |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 951 | * External storage devices returned here are considered a permanent part of |
| 952 | * the device, including both emulated external storage and physical media |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 953 | * slots, such as SD cards in a battery compartment. The returned paths do |
| 954 | * not include transient devices, such as USB flash drives. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 955 | * <p> |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 956 | * An application may store data on any or all of the returned devices. For |
| 957 | * example, an app may choose to store large files on the device with the |
| 958 | * most available space, as measured by {@link StatFs}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 959 | * <p> |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 960 | * No permissions are required to read or write to the returned paths; they |
| 961 | * are always accessible to the calling app. Write access outside of these |
| 962 | * paths on secondary external storage devices is not available. |
| 963 | * <p> |
| 964 | * The first path returned is the same as {@link #getExternalCacheDir()}. |
| 965 | * Returned paths may be {@code null} if a storage device is unavailable. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 966 | * |
| 967 | * @see #getExternalCacheDir() |
Jeff Sharkey | 4ca728c | 2014-01-10 16:27:19 -0800 | [diff] [blame] | 968 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 969 | */ |
| 970 | public abstract File[] getExternalCacheDirs(); |
| 971 | |
| 972 | /** |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 973 | * Returns absolute paths to application-specific directories on all |
| 974 | * external storage devices where the application can place media files. |
| 975 | * These files are scanned and made available to other apps through |
| 976 | * {@link MediaStore}. |
| 977 | * <p> |
| 978 | * This is like {@link #getExternalFilesDirs} in that these files will be |
| 979 | * deleted when the application is uninstalled, however there are some |
| 980 | * important differences: |
| 981 | * <ul> |
| 982 | * <li>External files are not always available: they will disappear if the |
| 983 | * user mounts the external storage on a computer or removes it. |
| 984 | * <li>There is no security enforced with these files. |
| 985 | * </ul> |
| 986 | * <p> |
| 987 | * External storage devices returned here are considered a permanent part of |
| 988 | * the device, including both emulated external storage and physical media |
| 989 | * slots, such as SD cards in a battery compartment. The returned paths do |
| 990 | * not include transient devices, such as USB flash drives. |
| 991 | * <p> |
| 992 | * An application may store data on any or all of the returned devices. For |
| 993 | * example, an app may choose to store large files on the device with the |
| 994 | * most available space, as measured by {@link StatFs}. |
| 995 | * <p> |
| 996 | * No permissions are required to read or write to the returned paths; they |
| 997 | * are always accessible to the calling app. Write access outside of these |
| 998 | * paths on secondary external storage devices is not available. |
| 999 | * <p> |
| 1000 | * Returned paths may be {@code null} if a storage device is unavailable. |
| 1001 | * |
| 1002 | * @see Environment#getExternalStorageState(File) |
| 1003 | */ |
| 1004 | public abstract File[] getExternalMediaDirs(); |
| 1005 | |
| 1006 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1007 | * Returns an array of strings naming the private files associated with |
| 1008 | * this Context's application package. |
| 1009 | * |
| 1010 | * @return Array of strings naming the private files. |
| 1011 | * |
| 1012 | * @see #openFileInput |
| 1013 | * @see #openFileOutput |
| 1014 | * @see #deleteFile |
| 1015 | */ |
| 1016 | public abstract String[] fileList(); |
| 1017 | |
| 1018 | /** |
| 1019 | * Retrieve, creating if needed, a new directory in which the application |
| 1020 | * can place its own custom data files. You can use the returned File |
| 1021 | * object to create and access files in this directory. Note that files |
| 1022 | * created through a File object will only be accessible by your own |
| 1023 | * application; you can only set the mode of the entire directory, not |
| 1024 | * of individual files. |
| 1025 | * |
Nick Kralevich | 92091fa | 2012-12-12 16:24:31 -0800 | [diff] [blame] | 1026 | * @param name Name of the directory to retrieve. This is a directory |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1027 | * that is created as part of your application data. |
Nick Kralevich | 92091fa | 2012-12-12 16:24:31 -0800 | [diff] [blame] | 1028 | * @param mode Operating mode. Use 0 or {@link #MODE_PRIVATE} for the |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1029 | * default operation, {@link #MODE_WORLD_READABLE} and |
| 1030 | * {@link #MODE_WORLD_WRITEABLE} to control permissions. |
| 1031 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1032 | * @return A {@link File} object for the requested directory. The directory |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1033 | * will have been created if it does not already exist. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1034 | * |
| 1035 | * @see #openFileOutput(String, int) |
| 1036 | */ |
| 1037 | public abstract File getDir(String name, int mode); |
| 1038 | |
| 1039 | /** |
| 1040 | * Open a new private SQLiteDatabase associated with this Context's |
| 1041 | * application package. Create the database file if it doesn't exist. |
| 1042 | * |
| 1043 | * @param name The name (unique in the application package) of the database. |
| 1044 | * @param mode Operating mode. Use 0 or {@link #MODE_PRIVATE} for the |
| 1045 | * default operation, {@link #MODE_WORLD_READABLE} |
| 1046 | * and {@link #MODE_WORLD_WRITEABLE} to control permissions. |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 1047 | * Use {@link #MODE_ENABLE_WRITE_AHEAD_LOGGING} to enable write-ahead logging by default. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1048 | * @param factory An optional factory class that is called to instantiate a |
| 1049 | * cursor when query is called. |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1050 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1051 | * @return The contents of a newly created database with the given name. |
| 1052 | * @throws android.database.sqlite.SQLiteException if the database file could not be opened. |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1053 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1054 | * @see #MODE_PRIVATE |
| 1055 | * @see #MODE_WORLD_READABLE |
| 1056 | * @see #MODE_WORLD_WRITEABLE |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 1057 | * @see #MODE_ENABLE_WRITE_AHEAD_LOGGING |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1058 | * @see #deleteDatabase |
| 1059 | */ |
| 1060 | public abstract SQLiteDatabase openOrCreateDatabase(String name, |
| 1061 | int mode, CursorFactory factory); |
| 1062 | |
| 1063 | /** |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1064 | * Open a new private SQLiteDatabase associated with this Context's |
| 1065 | * application package. Creates the database file if it doesn't exist. |
| 1066 | * |
| 1067 | * <p>Accepts input param: a concrete instance of {@link DatabaseErrorHandler} to be |
| 1068 | * used to handle corruption when sqlite reports database corruption.</p> |
| 1069 | * |
| 1070 | * @param name The name (unique in the application package) of the database. |
| 1071 | * @param mode Operating mode. Use 0 or {@link #MODE_PRIVATE} for the |
| 1072 | * default operation, {@link #MODE_WORLD_READABLE} |
| 1073 | * and {@link #MODE_WORLD_WRITEABLE} to control permissions. |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 1074 | * Use {@link #MODE_ENABLE_WRITE_AHEAD_LOGGING} to enable write-ahead logging by default. |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1075 | * @param factory An optional factory class that is called to instantiate a |
| 1076 | * cursor when query is called. |
| 1077 | * @param errorHandler the {@link DatabaseErrorHandler} to be used when sqlite reports database |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1078 | * corruption. if null, {@link android.database.DefaultDatabaseErrorHandler} is assumed. |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1079 | * @return The contents of a newly created database with the given name. |
| 1080 | * @throws android.database.sqlite.SQLiteException if the database file could not be opened. |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1081 | * |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1082 | * @see #MODE_PRIVATE |
| 1083 | * @see #MODE_WORLD_READABLE |
| 1084 | * @see #MODE_WORLD_WRITEABLE |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 1085 | * @see #MODE_ENABLE_WRITE_AHEAD_LOGGING |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1086 | * @see #deleteDatabase |
| 1087 | */ |
| 1088 | public abstract SQLiteDatabase openOrCreateDatabase(String name, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1089 | int mode, CursorFactory factory, |
| 1090 | @Nullable DatabaseErrorHandler errorHandler); |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1091 | |
| 1092 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1093 | * Delete an existing private SQLiteDatabase associated with this Context's |
| 1094 | * application package. |
| 1095 | * |
| 1096 | * @param name The name (unique in the application package) of the |
| 1097 | * database. |
| 1098 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1099 | * @return {@code true} if the database was successfully deleted; else {@code false}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1100 | * |
| 1101 | * @see #openOrCreateDatabase |
| 1102 | */ |
| 1103 | public abstract boolean deleteDatabase(String name); |
| 1104 | |
| 1105 | /** |
| 1106 | * Returns the absolute path on the filesystem where a database created with |
| 1107 | * {@link #openOrCreateDatabase} is stored. |
| 1108 | * |
| 1109 | * @param name The name of the database for which you would like to get |
| 1110 | * its path. |
| 1111 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1112 | * @return An absolute path to the given database. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1113 | * |
| 1114 | * @see #openOrCreateDatabase |
| 1115 | */ |
| 1116 | public abstract File getDatabasePath(String name); |
| 1117 | |
| 1118 | /** |
| 1119 | * Returns an array of strings naming the private databases associated with |
| 1120 | * this Context's application package. |
| 1121 | * |
| 1122 | * @return Array of strings naming the private databases. |
| 1123 | * |
| 1124 | * @see #openOrCreateDatabase |
| 1125 | * @see #deleteDatabase |
| 1126 | */ |
| 1127 | public abstract String[] databaseList(); |
| 1128 | |
| 1129 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1130 | * @deprecated Use {@link android.app.WallpaperManager#getDrawable |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1131 | * WallpaperManager.get()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1132 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1133 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1134 | public abstract Drawable getWallpaper(); |
| 1135 | |
| 1136 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1137 | * @deprecated Use {@link android.app.WallpaperManager#peekDrawable |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1138 | * WallpaperManager.peek()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1139 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1140 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1141 | public abstract Drawable peekWallpaper(); |
| 1142 | |
| 1143 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1144 | * @deprecated Use {@link android.app.WallpaperManager#getDesiredMinimumWidth() |
| 1145 | * WallpaperManager.getDesiredMinimumWidth()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1146 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1147 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1148 | public abstract int getWallpaperDesiredMinimumWidth(); |
| 1149 | |
| 1150 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1151 | * @deprecated Use {@link android.app.WallpaperManager#getDesiredMinimumHeight() |
| 1152 | * WallpaperManager.getDesiredMinimumHeight()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1153 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1154 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1155 | public abstract int getWallpaperDesiredMinimumHeight(); |
| 1156 | |
| 1157 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1158 | * @deprecated Use {@link android.app.WallpaperManager#setBitmap(Bitmap) |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1159 | * WallpaperManager.set()} instead. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 1160 | * <p>This method requires the caller to hold the permission |
| 1161 | * {@link android.Manifest.permission#SET_WALLPAPER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1162 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1163 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1164 | public abstract void setWallpaper(Bitmap bitmap) throws IOException; |
| 1165 | |
| 1166 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1167 | * @deprecated Use {@link android.app.WallpaperManager#setStream(InputStream) |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1168 | * WallpaperManager.set()} instead. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 1169 | * <p>This method requires the caller to hold the permission |
| 1170 | * {@link android.Manifest.permission#SET_WALLPAPER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1171 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1172 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1173 | public abstract void setWallpaper(InputStream data) throws IOException; |
| 1174 | |
| 1175 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1176 | * @deprecated Use {@link android.app.WallpaperManager#clear |
| 1177 | * WallpaperManager.clear()} instead. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 1178 | * <p>This method requires the caller to hold the permission |
| 1179 | * {@link android.Manifest.permission#SET_WALLPAPER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1180 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1181 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1182 | public abstract void clearWallpaper() throws IOException; |
| 1183 | |
| 1184 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1185 | * Same as {@link #startActivity(Intent, Bundle)} with no options |
| 1186 | * specified. |
| 1187 | * |
| 1188 | * @param intent The description of the activity to start. |
| 1189 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1190 | * @throws ActivityNotFoundException |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1191 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1192 | * @see #startActivity(Intent, Bundle) |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1193 | * @see PackageManager#resolveActivity |
| 1194 | */ |
| 1195 | public abstract void startActivity(Intent intent); |
| 1196 | |
| 1197 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1198 | * Version of {@link #startActivity(Intent)} that allows you to specify the |
| 1199 | * user the activity will be started for. This is not available to applications |
| 1200 | * that are not pre-installed on the system image. Using it requires holding |
| 1201 | * the INTERACT_ACROSS_USERS_FULL permission. |
Amith Yamasani | 8264408 | 2012-08-03 13:09:11 -0700 | [diff] [blame] | 1202 | * @param intent The description of the activity to start. |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 1203 | * @param user The UserHandle of the user to start this activity for. |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1204 | * @throws ActivityNotFoundException |
Amith Yamasani | 8264408 | 2012-08-03 13:09:11 -0700 | [diff] [blame] | 1205 | * @hide |
| 1206 | */ |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 1207 | public void startActivityAsUser(Intent intent, UserHandle user) { |
Amith Yamasani | 8264408 | 2012-08-03 13:09:11 -0700 | [diff] [blame] | 1208 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1209 | } |
| 1210 | |
| 1211 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1212 | * Launch a new activity. You will not receive any information about when |
| 1213 | * the activity exits. |
| 1214 | * |
| 1215 | * <p>Note that if this method is being called from outside of an |
| 1216 | * {@link android.app.Activity} Context, then the Intent must include |
| 1217 | * the {@link Intent#FLAG_ACTIVITY_NEW_TASK} launch flag. This is because, |
| 1218 | * without being started from an existing Activity, there is no existing |
| 1219 | * task in which to place the new activity and thus it needs to be placed |
| 1220 | * in its own separate task. |
| 1221 | * |
| 1222 | * <p>This method throws {@link ActivityNotFoundException} |
| 1223 | * if there was no Activity found to run the given Intent. |
| 1224 | * |
| 1225 | * @param intent The description of the activity to start. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1226 | * @param options Additional options for how the Activity should be started. |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 1227 | * May be null if there are no options. See {@link android.app.ActivityOptions} |
| 1228 | * for how to build the Bundle supplied here; there are no supported definitions |
| 1229 | * for building it manually. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1230 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1231 | * @throws ActivityNotFoundException |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1232 | * |
Scott Main | 60dd520 | 2012-06-23 00:01:22 -0700 | [diff] [blame] | 1233 | * @see #startActivity(Intent) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1234 | * @see PackageManager#resolveActivity |
| 1235 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1236 | public abstract void startActivity(Intent intent, @Nullable Bundle options); |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1237 | |
| 1238 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1239 | * Version of {@link #startActivity(Intent, Bundle)} that allows you to specify the |
| 1240 | * user the activity will be started for. This is not available to applications |
| 1241 | * that are not pre-installed on the system image. Using it requires holding |
| 1242 | * the INTERACT_ACROSS_USERS_FULL permission. |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 1243 | * @param intent The description of the activity to start. |
| 1244 | * @param options Additional options for how the Activity should be started. |
| 1245 | * May be null if there are no options. See {@link android.app.ActivityOptions} |
| 1246 | * for how to build the Bundle supplied here; there are no supported definitions |
| 1247 | * for building it manually. |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 1248 | * @param userId The UserHandle of the user to start this activity for. |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1249 | * @throws ActivityNotFoundException |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 1250 | * @hide |
| 1251 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1252 | public void startActivityAsUser(Intent intent, @Nullable Bundle options, UserHandle userId) { |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 1253 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1254 | } |
| 1255 | |
| 1256 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1257 | * Same as {@link #startActivities(Intent[], Bundle)} with no options |
| 1258 | * specified. |
| 1259 | * |
| 1260 | * @param intents An array of Intents to be started. |
| 1261 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1262 | * @throws ActivityNotFoundException |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1263 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1264 | * @see #startActivities(Intent[], Bundle) |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1265 | * @see PackageManager#resolveActivity |
| 1266 | */ |
| 1267 | public abstract void startActivities(Intent[] intents); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1268 | |
| 1269 | /** |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1270 | * Launch multiple new activities. This is generally the same as calling |
| 1271 | * {@link #startActivity(Intent)} for the first Intent in the array, |
| 1272 | * that activity during its creation calling {@link #startActivity(Intent)} |
| 1273 | * for the second entry, etc. Note that unlike that approach, generally |
| 1274 | * none of the activities except the last in the array will be created |
| 1275 | * at this point, but rather will be created when the user first visits |
| 1276 | * them (due to pressing back from the activity on top). |
| 1277 | * |
| 1278 | * <p>This method throws {@link ActivityNotFoundException} |
| 1279 | * if there was no Activity found for <em>any</em> given Intent. In this |
| 1280 | * case the state of the activity stack is undefined (some Intents in the |
| 1281 | * list may be on it, some not), so you probably want to avoid such situations. |
| 1282 | * |
| 1283 | * @param intents An array of Intents to be started. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1284 | * @param options Additional options for how the Activity should be started. |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 1285 | * See {@link android.content.Context#startActivity(Intent, Bundle) |
| 1286 | * Context.startActivity(Intent, Bundle)} for more details. |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1287 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1288 | * @throws ActivityNotFoundException |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1289 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1290 | * @see #startActivities(Intent[]) |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1291 | * @see PackageManager#resolveActivity |
| 1292 | */ |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1293 | public abstract void startActivities(Intent[] intents, Bundle options); |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1294 | |
| 1295 | /** |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1296 | * @hide |
| 1297 | * Launch multiple new activities. This is generally the same as calling |
| 1298 | * {@link #startActivity(Intent)} for the first Intent in the array, |
| 1299 | * that activity during its creation calling {@link #startActivity(Intent)} |
| 1300 | * for the second entry, etc. Note that unlike that approach, generally |
| 1301 | * none of the activities except the last in the array will be created |
| 1302 | * at this point, but rather will be created when the user first visits |
| 1303 | * them (due to pressing back from the activity on top). |
| 1304 | * |
| 1305 | * <p>This method throws {@link ActivityNotFoundException} |
| 1306 | * if there was no Activity found for <em>any</em> given Intent. In this |
| 1307 | * case the state of the activity stack is undefined (some Intents in the |
| 1308 | * list may be on it, some not), so you probably want to avoid such situations. |
| 1309 | * |
| 1310 | * @param intents An array of Intents to be started. |
| 1311 | * @param options Additional options for how the Activity should be started. |
| 1312 | * @param userHandle The user for whom to launch the activities |
| 1313 | * See {@link android.content.Context#startActivity(Intent, Bundle) |
| 1314 | * Context.startActivity(Intent, Bundle)} for more details. |
| 1315 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1316 | * @throws ActivityNotFoundException |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1317 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1318 | * @see #startActivities(Intent[]) |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1319 | * @see PackageManager#resolveActivity |
| 1320 | */ |
| 1321 | public void startActivitiesAsUser(Intent[] intents, Bundle options, UserHandle userHandle) { |
| 1322 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1323 | } |
| 1324 | |
| 1325 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1326 | * Same as {@link #startIntentSender(IntentSender, Intent, int, int, int, Bundle)} |
| 1327 | * with no options specified. |
| 1328 | * |
| 1329 | * @param intent The IntentSender to launch. |
| 1330 | * @param fillInIntent If non-null, this will be provided as the |
| 1331 | * intent parameter to {@link IntentSender#sendIntent}. |
| 1332 | * @param flagsMask Intent flags in the original IntentSender that you |
| 1333 | * would like to change. |
| 1334 | * @param flagsValues Desired values for any bits set in |
| 1335 | * <var>flagsMask</var> |
| 1336 | * @param extraFlags Always set to 0. |
| 1337 | * |
| 1338 | * @see #startActivity(Intent) |
| 1339 | * @see #startIntentSender(IntentSender, Intent, int, int, int, Bundle) |
| 1340 | */ |
| 1341 | public abstract void startIntentSender(IntentSender intent, |
| 1342 | Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags) |
| 1343 | throws IntentSender.SendIntentException; |
| 1344 | |
| 1345 | /** |
| 1346 | * Like {@link #startActivity(Intent, Bundle)}, but taking a IntentSender |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1347 | * to start. If the IntentSender is for an activity, that activity will be started |
Dianne Hackborn | ae22c05 | 2009-09-17 18:46:22 -0700 | [diff] [blame] | 1348 | * as if you had called the regular {@link #startActivity(Intent)} |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1349 | * here; otherwise, its associated action will be executed (such as |
| 1350 | * sending a broadcast) as if you had called |
| 1351 | * {@link IntentSender#sendIntent IntentSender.sendIntent} on it. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1352 | * |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1353 | * @param intent The IntentSender to launch. |
| 1354 | * @param fillInIntent If non-null, this will be provided as the |
| 1355 | * intent parameter to {@link IntentSender#sendIntent}. |
| 1356 | * @param flagsMask Intent flags in the original IntentSender that you |
| 1357 | * would like to change. |
| 1358 | * @param flagsValues Desired values for any bits set in |
| 1359 | * <var>flagsMask</var> |
| 1360 | * @param extraFlags Always set to 0. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1361 | * @param options Additional options for how the Activity should be started. |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 1362 | * See {@link android.content.Context#startActivity(Intent, Bundle) |
| 1363 | * Context.startActivity(Intent, Bundle)} for more details. If options |
| 1364 | * have also been supplied by the IntentSender, options given here will |
| 1365 | * override any that conflict with those given by the IntentSender. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1366 | * |
| 1367 | * @see #startActivity(Intent, Bundle) |
| 1368 | * @see #startIntentSender(IntentSender, Intent, int, int, int) |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1369 | */ |
| 1370 | public abstract void startIntentSender(IntentSender intent, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1371 | @Nullable Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags, |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1372 | Bundle options) throws IntentSender.SendIntentException; |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1373 | |
| 1374 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1375 | * Broadcast the given intent to all interested BroadcastReceivers. This |
| 1376 | * call is asynchronous; it returns immediately, and you will continue |
| 1377 | * executing while the receivers are run. No results are propagated from |
| 1378 | * receivers and receivers can not abort the broadcast. If you want |
| 1379 | * to allow receivers to propagate results or abort the broadcast, you must |
| 1380 | * send an ordered broadcast using |
| 1381 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 1382 | * |
| 1383 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1384 | * |
| 1385 | * @param intent The Intent to broadcast; all receivers matching this |
| 1386 | * Intent will receive the broadcast. |
| 1387 | * |
| 1388 | * @see android.content.BroadcastReceiver |
| 1389 | * @see #registerReceiver |
| 1390 | * @see #sendBroadcast(Intent, String) |
| 1391 | * @see #sendOrderedBroadcast(Intent, String) |
| 1392 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 1393 | */ |
| 1394 | public abstract void sendBroadcast(Intent intent); |
| 1395 | |
| 1396 | /** |
| 1397 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
| 1398 | * an optional required permission to be enforced. This |
| 1399 | * call is asynchronous; it returns immediately, and you will continue |
| 1400 | * executing while the receivers are run. No results are propagated from |
| 1401 | * receivers and receivers can not abort the broadcast. If you want |
| 1402 | * to allow receivers to propagate results or abort the broadcast, you must |
| 1403 | * send an ordered broadcast using |
| 1404 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 1405 | * |
| 1406 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1407 | * |
| 1408 | * @param intent The Intent to broadcast; all receivers matching this |
| 1409 | * Intent will receive the broadcast. |
Brad Fitzpatrick | 26b71be | 2010-12-07 14:52:58 -0800 | [diff] [blame] | 1410 | * @param receiverPermission (optional) String naming a permission that |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1411 | * a receiver must hold in order to receive your broadcast. |
| 1412 | * If null, no permission is required. |
| 1413 | * |
| 1414 | * @see android.content.BroadcastReceiver |
| 1415 | * @see #registerReceiver |
| 1416 | * @see #sendBroadcast(Intent) |
| 1417 | * @see #sendOrderedBroadcast(Intent, String) |
| 1418 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 1419 | */ |
| 1420 | public abstract void sendBroadcast(Intent intent, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1421 | @Nullable String receiverPermission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1422 | |
| 1423 | /** |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 1424 | * Like {@link #sendBroadcast(Intent, String)}, but also allows specification |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1425 | * of an associated app op as per {@link android.app.AppOpsManager}. |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 1426 | * @hide |
| 1427 | */ |
| 1428 | public abstract void sendBroadcast(Intent intent, |
| 1429 | String receiverPermission, int appOp); |
| 1430 | |
| 1431 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1432 | * Broadcast the given intent to all interested BroadcastReceivers, delivering |
| 1433 | * them one at a time to allow more preferred receivers to consume the |
| 1434 | * broadcast before it is delivered to less preferred receivers. This |
| 1435 | * call is asynchronous; it returns immediately, and you will continue |
| 1436 | * executing while the receivers are run. |
| 1437 | * |
| 1438 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1439 | * |
| 1440 | * @param intent The Intent to broadcast; all receivers matching this |
| 1441 | * Intent will receive the broadcast. |
| 1442 | * @param receiverPermission (optional) String naming a permissions that |
| 1443 | * a receiver must hold in order to receive your broadcast. |
| 1444 | * If null, no permission is required. |
| 1445 | * |
| 1446 | * @see android.content.BroadcastReceiver |
| 1447 | * @see #registerReceiver |
| 1448 | * @see #sendBroadcast(Intent) |
| 1449 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 1450 | */ |
| 1451 | public abstract void sendOrderedBroadcast(Intent intent, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1452 | @Nullable String receiverPermission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1453 | |
| 1454 | /** |
| 1455 | * Version of {@link #sendBroadcast(Intent)} that allows you to |
| 1456 | * receive data back from the broadcast. This is accomplished by |
| 1457 | * supplying your own BroadcastReceiver when calling, which will be |
| 1458 | * treated as a final receiver at the end of the broadcast -- its |
| 1459 | * {@link BroadcastReceiver#onReceive} method will be called with |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 1460 | * the result values collected from the other receivers. The broadcast will |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1461 | * be serialized in the same way as calling |
| 1462 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 1463 | * |
| 1464 | * <p>Like {@link #sendBroadcast(Intent)}, this method is |
| 1465 | * asynchronous; it will return before |
| 1466 | * resultReceiver.onReceive() is called. |
| 1467 | * |
| 1468 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1469 | * |
| 1470 | * @param intent The Intent to broadcast; all receivers matching this |
| 1471 | * Intent will receive the broadcast. |
| 1472 | * @param receiverPermission String naming a permissions that |
| 1473 | * a receiver must hold in order to receive your broadcast. |
| 1474 | * If null, no permission is required. |
| 1475 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 1476 | * receiver of the broadcast. |
| 1477 | * @param scheduler A custom Handler with which to schedule the |
| 1478 | * resultReceiver callback; if null it will be |
| 1479 | * scheduled in the Context's main thread. |
| 1480 | * @param initialCode An initial value for the result code. Often |
| 1481 | * Activity.RESULT_OK. |
| 1482 | * @param initialData An initial value for the result data. Often |
| 1483 | * null. |
| 1484 | * @param initialExtras An initial value for the result extras. Often |
| 1485 | * null. |
| 1486 | * |
| 1487 | * @see #sendBroadcast(Intent) |
| 1488 | * @see #sendBroadcast(Intent, String) |
| 1489 | * @see #sendOrderedBroadcast(Intent, String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1490 | * @see android.content.BroadcastReceiver |
| 1491 | * @see #registerReceiver |
| 1492 | * @see android.app.Activity#RESULT_OK |
| 1493 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1494 | public abstract void sendOrderedBroadcast(@NonNull Intent intent, |
| 1495 | @Nullable String receiverPermission, BroadcastReceiver resultReceiver, |
| 1496 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 1497 | @Nullable Bundle initialExtras); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1498 | |
| 1499 | /** |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 1500 | * Like {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, android.os.Handler, |
| 1501 | * int, String, android.os.Bundle)}, but also allows specification |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1502 | * of an associated app op as per {@link android.app.AppOpsManager}. |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 1503 | * @hide |
| 1504 | */ |
| 1505 | public abstract void sendOrderedBroadcast(Intent intent, |
| 1506 | String receiverPermission, int appOp, BroadcastReceiver resultReceiver, |
| 1507 | Handler scheduler, int initialCode, String initialData, |
| 1508 | Bundle initialExtras); |
| 1509 | |
| 1510 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1511 | * Version of {@link #sendBroadcast(Intent)} that allows you to specify the |
| 1512 | * user the broadcast will be sent to. This is not available to applications |
| 1513 | * that are not pre-installed on the system image. Using it requires holding |
| 1514 | * the INTERACT_ACROSS_USERS permission. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 1515 | * @param intent The intent to broadcast |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 1516 | * @param user UserHandle to send the intent to. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 1517 | * @see #sendBroadcast(Intent) |
| 1518 | */ |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 1519 | public abstract void sendBroadcastAsUser(Intent intent, UserHandle user); |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 1520 | |
| 1521 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1522 | * Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the |
| 1523 | * user the broadcast will be sent to. This is not available to applications |
| 1524 | * that are not pre-installed on the system image. Using it requires holding |
| 1525 | * the INTERACT_ACROSS_USERS permission. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1526 | * |
| 1527 | * @param intent The Intent to broadcast; all receivers matching this |
| 1528 | * Intent will receive the broadcast. |
| 1529 | * @param user UserHandle to send the intent to. |
| 1530 | * @param receiverPermission (optional) String naming a permission that |
| 1531 | * a receiver must hold in order to receive your broadcast. |
| 1532 | * If null, no permission is required. |
| 1533 | * |
| 1534 | * @see #sendBroadcast(Intent, String) |
| 1535 | */ |
| 1536 | public abstract void sendBroadcastAsUser(Intent intent, UserHandle user, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1537 | @Nullable String receiverPermission); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1538 | |
| 1539 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1540 | * Version of |
| 1541 | * {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)} |
| 1542 | * that allows you to specify the |
| 1543 | * user the broadcast will be sent to. This is not available to applications |
| 1544 | * that are not pre-installed on the system image. Using it requires holding |
| 1545 | * the INTERACT_ACROSS_USERS permission. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 1546 | * |
| 1547 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1548 | * |
| 1549 | * @param intent The Intent to broadcast; all receivers matching this |
| 1550 | * Intent will receive the broadcast. |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 1551 | * @param user UserHandle to send the intent to. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1552 | * @param receiverPermission String naming a permissions that |
| 1553 | * a receiver must hold in order to receive your broadcast. |
| 1554 | * If null, no permission is required. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 1555 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 1556 | * receiver of the broadcast. |
| 1557 | * @param scheduler A custom Handler with which to schedule the |
| 1558 | * resultReceiver callback; if null it will be |
| 1559 | * scheduled in the Context's main thread. |
| 1560 | * @param initialCode An initial value for the result code. Often |
| 1561 | * Activity.RESULT_OK. |
| 1562 | * @param initialData An initial value for the result data. Often |
| 1563 | * null. |
| 1564 | * @param initialExtras An initial value for the result extras. Often |
| 1565 | * null. |
| 1566 | * |
| 1567 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 1568 | */ |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 1569 | public abstract void sendOrderedBroadcastAsUser(Intent intent, UserHandle user, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1570 | @Nullable String receiverPermission, BroadcastReceiver resultReceiver, |
| 1571 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 1572 | @Nullable Bundle initialExtras); |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 1573 | |
| 1574 | /** |
Amith Yamasani | 3cf7572 | 2014-05-16 12:37:29 -0700 | [diff] [blame] | 1575 | * Similar to above but takes an appOp as well, to enforce restrictions. |
| 1576 | * @see #sendOrderedBroadcastAsUser(Intent, UserHandle, String, |
| 1577 | * BroadcastReceiver, Handler, int, String, Bundle) |
| 1578 | * @hide |
| 1579 | */ |
| 1580 | public abstract void sendOrderedBroadcastAsUser(Intent intent, UserHandle user, |
| 1581 | @Nullable String receiverPermission, int appOp, BroadcastReceiver resultReceiver, |
| 1582 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 1583 | @Nullable Bundle initialExtras); |
| 1584 | |
| 1585 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1586 | * <p>Perform a {@link #sendBroadcast(Intent)} that is "sticky," meaning the |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1587 | * Intent you are sending stays around after the broadcast is complete, |
| 1588 | * so that others can quickly retrieve that data through the return |
| 1589 | * value of {@link #registerReceiver(BroadcastReceiver, IntentFilter)}. In |
| 1590 | * all other ways, this behaves the same as |
| 1591 | * {@link #sendBroadcast(Intent)}. |
| 1592 | * |
| 1593 | * <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY} |
| 1594 | * permission in order to use this API. If you do not hold that |
| 1595 | * permission, {@link SecurityException} will be thrown. |
| 1596 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1597 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 1598 | * can access them), no protection (anyone can modify them), and many other problems. |
| 1599 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 1600 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 1601 | * desired. |
| 1602 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1603 | * @param intent The Intent to broadcast; all receivers matching this |
| 1604 | * Intent will receive the broadcast, and the Intent will be held to |
| 1605 | * be re-broadcast to future receivers. |
| 1606 | * |
| 1607 | * @see #sendBroadcast(Intent) |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 1608 | * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1609 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1610 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1611 | public abstract void sendStickyBroadcast(Intent intent); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1612 | |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 1613 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1614 | * <p>Version of {@link #sendStickyBroadcast} that allows you to |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 1615 | * receive data back from the broadcast. This is accomplished by |
| 1616 | * supplying your own BroadcastReceiver when calling, which will be |
| 1617 | * treated as a final receiver at the end of the broadcast -- its |
| 1618 | * {@link BroadcastReceiver#onReceive} method will be called with |
| 1619 | * the result values collected from the other receivers. The broadcast will |
| 1620 | * be serialized in the same way as calling |
| 1621 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 1622 | * |
| 1623 | * <p>Like {@link #sendBroadcast(Intent)}, this method is |
| 1624 | * asynchronous; it will return before |
| 1625 | * resultReceiver.onReceive() is called. Note that the sticky data |
| 1626 | * stored is only the data you initially supply to the broadcast, not |
| 1627 | * the result of any changes made by the receivers. |
| 1628 | * |
| 1629 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1630 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1631 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 1632 | * can access them), no protection (anyone can modify them), and many other problems. |
| 1633 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 1634 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 1635 | * desired. |
| 1636 | * |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 1637 | * @param intent The Intent to broadcast; all receivers matching this |
| 1638 | * Intent will receive the broadcast. |
| 1639 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 1640 | * receiver of the broadcast. |
| 1641 | * @param scheduler A custom Handler with which to schedule the |
| 1642 | * resultReceiver callback; if null it will be |
| 1643 | * scheduled in the Context's main thread. |
| 1644 | * @param initialCode An initial value for the result code. Often |
| 1645 | * Activity.RESULT_OK. |
| 1646 | * @param initialData An initial value for the result data. Often |
| 1647 | * null. |
| 1648 | * @param initialExtras An initial value for the result extras. Often |
| 1649 | * null. |
| 1650 | * |
| 1651 | * @see #sendBroadcast(Intent) |
| 1652 | * @see #sendBroadcast(Intent, String) |
| 1653 | * @see #sendOrderedBroadcast(Intent, String) |
| 1654 | * @see #sendStickyBroadcast(Intent) |
| 1655 | * @see android.content.BroadcastReceiver |
| 1656 | * @see #registerReceiver |
| 1657 | * @see android.app.Activity#RESULT_OK |
| 1658 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1659 | @Deprecated |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 1660 | public abstract void sendStickyOrderedBroadcast(Intent intent, |
| 1661 | BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1662 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 1663 | @Nullable Bundle initialExtras); |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 1664 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1665 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1666 | * <p>Remove the data previously sent with {@link #sendStickyBroadcast}, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1667 | * so that it is as if the sticky broadcast had never happened. |
| 1668 | * |
| 1669 | * <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY} |
| 1670 | * permission in order to use this API. If you do not hold that |
| 1671 | * permission, {@link SecurityException} will be thrown. |
| 1672 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1673 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 1674 | * can access them), no protection (anyone can modify them), and many other problems. |
| 1675 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 1676 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 1677 | * desired. |
| 1678 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1679 | * @param intent The Intent that was previously broadcast. |
| 1680 | * |
| 1681 | * @see #sendStickyBroadcast |
| 1682 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1683 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1684 | public abstract void removeStickyBroadcast(Intent intent); |
| 1685 | |
| 1686 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1687 | * <p>Version of {@link #sendStickyBroadcast(Intent)} that allows you to specify the |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1688 | * user the broadcast will be sent to. This is not available to applications |
| 1689 | * that are not pre-installed on the system image. Using it requires holding |
| 1690 | * the INTERACT_ACROSS_USERS permission. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1691 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1692 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 1693 | * can access them), no protection (anyone can modify them), and many other problems. |
| 1694 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 1695 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 1696 | * desired. |
| 1697 | * |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1698 | * @param intent The Intent to broadcast; all receivers matching this |
| 1699 | * Intent will receive the broadcast, and the Intent will be held to |
| 1700 | * be re-broadcast to future receivers. |
| 1701 | * @param user UserHandle to send the intent to. |
| 1702 | * |
| 1703 | * @see #sendBroadcast(Intent) |
| 1704 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1705 | @Deprecated |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1706 | public abstract void sendStickyBroadcastAsUser(Intent intent, UserHandle user); |
| 1707 | |
| 1708 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1709 | * <p>Version of |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1710 | * {@link #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)} |
| 1711 | * that allows you to specify the |
| 1712 | * user the broadcast will be sent to. This is not available to applications |
| 1713 | * that are not pre-installed on the system image. Using it requires holding |
| 1714 | * the INTERACT_ACROSS_USERS permission. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1715 | * |
| 1716 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1717 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1718 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 1719 | * can access them), no protection (anyone can modify them), and many other problems. |
| 1720 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 1721 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 1722 | * desired. |
| 1723 | * |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1724 | * @param intent The Intent to broadcast; all receivers matching this |
| 1725 | * Intent will receive the broadcast. |
| 1726 | * @param user UserHandle to send the intent to. |
| 1727 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 1728 | * receiver of the broadcast. |
| 1729 | * @param scheduler A custom Handler with which to schedule the |
| 1730 | * resultReceiver callback; if null it will be |
| 1731 | * scheduled in the Context's main thread. |
| 1732 | * @param initialCode An initial value for the result code. Often |
| 1733 | * Activity.RESULT_OK. |
| 1734 | * @param initialData An initial value for the result data. Often |
| 1735 | * null. |
| 1736 | * @param initialExtras An initial value for the result extras. Often |
| 1737 | * null. |
| 1738 | * |
| 1739 | * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle) |
| 1740 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1741 | @Deprecated |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1742 | public abstract void sendStickyOrderedBroadcastAsUser(Intent intent, |
| 1743 | UserHandle user, BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1744 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 1745 | @Nullable Bundle initialExtras); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1746 | |
| 1747 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1748 | * <p>Version of {@link #removeStickyBroadcast(Intent)} that allows you to specify the |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1749 | * user the broadcast will be sent to. This is not available to applications |
| 1750 | * that are not pre-installed on the system image. Using it requires holding |
| 1751 | * the INTERACT_ACROSS_USERS permission. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1752 | * |
| 1753 | * <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY} |
| 1754 | * permission in order to use this API. If you do not hold that |
| 1755 | * permission, {@link SecurityException} will be thrown. |
| 1756 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1757 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 1758 | * can access them), no protection (anyone can modify them), and many other problems. |
| 1759 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 1760 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 1761 | * desired. |
| 1762 | * |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1763 | * @param intent The Intent that was previously broadcast. |
| 1764 | * @param user UserHandle to remove the sticky broadcast from. |
| 1765 | * |
| 1766 | * @see #sendStickyBroadcastAsUser |
| 1767 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1768 | @Deprecated |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1769 | public abstract void removeStickyBroadcastAsUser(Intent intent, UserHandle user); |
| 1770 | |
| 1771 | /** |
Chris Tate | a34df8a2 | 2009-04-02 23:15:58 -0700 | [diff] [blame] | 1772 | * Register a BroadcastReceiver to be run in the main activity thread. The |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1773 | * <var>receiver</var> will be called with any broadcast Intent that |
| 1774 | * matches <var>filter</var>, in the main application thread. |
| 1775 | * |
| 1776 | * <p>The system may broadcast Intents that are "sticky" -- these stay |
| 1777 | * around after the broadcast as finished, to be sent to any later |
| 1778 | * registrations. If your IntentFilter matches one of these sticky |
| 1779 | * Intents, that Intent will be returned by this function |
| 1780 | * <strong>and</strong> sent to your <var>receiver</var> as if it had just |
| 1781 | * been broadcast. |
| 1782 | * |
| 1783 | * <p>There may be multiple sticky Intents that match <var>filter</var>, |
| 1784 | * in which case each of these will be sent to <var>receiver</var>. In |
| 1785 | * this case, only one of these can be returned directly by the function; |
| 1786 | * which of these that is returned is arbitrarily decided by the system. |
| 1787 | * |
| 1788 | * <p>If you know the Intent your are registering for is sticky, you can |
| 1789 | * supply null for your <var>receiver</var>. In this case, no receiver is |
| 1790 | * registered -- the function simply returns the sticky Intent that |
| 1791 | * matches <var>filter</var>. In the case of multiple matches, the same |
| 1792 | * rules as described above apply. |
| 1793 | * |
| 1794 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1795 | * |
Dianne Hackborn | 6c418d5 | 2011-06-29 14:05:33 -0700 | [diff] [blame] | 1796 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 1797 | * registered with this method will correctly respect the |
| 1798 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 1799 | * Prior to that, it would be ignored and delivered to all matching registered |
| 1800 | * receivers. Be careful if using this for security.</p> |
| 1801 | * |
Chris Tate | a34df8a2 | 2009-04-02 23:15:58 -0700 | [diff] [blame] | 1802 | * <p class="note">Note: this method <em>cannot be called from a |
| 1803 | * {@link BroadcastReceiver} component;</em> that is, from a BroadcastReceiver |
| 1804 | * that is declared in an application's manifest. It is okay, however, to call |
| 1805 | * this method from another BroadcastReceiver that has itself been registered |
| 1806 | * at run time with {@link #registerReceiver}, since the lifetime of such a |
| 1807 | * registered BroadcastReceiver is tied to the object that registered it.</p> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1808 | * |
| 1809 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 1810 | * @param filter Selects the Intent broadcasts to be received. |
| 1811 | * |
| 1812 | * @return The first sticky intent found that matches <var>filter</var>, |
| 1813 | * or null if there are none. |
| 1814 | * |
| 1815 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
| 1816 | * @see #sendBroadcast |
| 1817 | * @see #unregisterReceiver |
| 1818 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1819 | @Nullable |
| 1820 | public abstract Intent registerReceiver(@Nullable BroadcastReceiver receiver, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1821 | IntentFilter filter); |
| 1822 | |
| 1823 | /** |
| 1824 | * Register to receive intent broadcasts, to run in the context of |
| 1825 | * <var>scheduler</var>. See |
| 1826 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter)} for more |
| 1827 | * information. This allows you to enforce permissions on who can |
| 1828 | * broadcast intents to your receiver, or have the receiver run in |
| 1829 | * a different thread than the main application thread. |
| 1830 | * |
| 1831 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1832 | * |
Dianne Hackborn | 6c418d5 | 2011-06-29 14:05:33 -0700 | [diff] [blame] | 1833 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 1834 | * registered with this method will correctly respect the |
| 1835 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 1836 | * Prior to that, it would be ignored and delivered to all matching registered |
| 1837 | * receivers. Be careful if using this for security.</p> |
| 1838 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1839 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 1840 | * @param filter Selects the Intent broadcasts to be received. |
| 1841 | * @param broadcastPermission String naming a permissions that a |
| 1842 | * broadcaster must hold in order to send an Intent to you. If null, |
| 1843 | * no permission is required. |
| 1844 | * @param scheduler Handler identifying the thread that will receive |
| 1845 | * the Intent. If null, the main thread of the process will be used. |
| 1846 | * |
| 1847 | * @return The first sticky intent found that matches <var>filter</var>, |
| 1848 | * or null if there are none. |
| 1849 | * |
| 1850 | * @see #registerReceiver(BroadcastReceiver, IntentFilter) |
| 1851 | * @see #sendBroadcast |
| 1852 | * @see #unregisterReceiver |
| 1853 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1854 | @Nullable |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1855 | public abstract Intent registerReceiver(BroadcastReceiver receiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1856 | IntentFilter filter, @Nullable String broadcastPermission, |
| 1857 | @Nullable Handler scheduler); |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 1858 | |
| 1859 | /** |
| 1860 | * @hide |
| 1861 | * Same as {@link #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
| 1862 | * but for a specific user. This receiver will receiver broadcasts that |
| 1863 | * are sent to the requested user. It |
| 1864 | * requires holding the {@link android.Manifest.permission#INTERACT_ACROSS_USERS_FULL} |
| 1865 | * permission. |
| 1866 | * |
| 1867 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 1868 | * @param user UserHandle to send the intent to. |
| 1869 | * @param filter Selects the Intent broadcasts to be received. |
| 1870 | * @param broadcastPermission String naming a permissions that a |
| 1871 | * broadcaster must hold in order to send an Intent to you. If null, |
| 1872 | * no permission is required. |
| 1873 | * @param scheduler Handler identifying the thread that will receive |
| 1874 | * the Intent. If null, the main thread of the process will be used. |
| 1875 | * |
| 1876 | * @return The first sticky intent found that matches <var>filter</var>, |
| 1877 | * or null if there are none. |
| 1878 | * |
| 1879 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler |
| 1880 | * @see #sendBroadcast |
| 1881 | * @see #unregisterReceiver |
| 1882 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1883 | @Nullable |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 1884 | public abstract Intent registerReceiverAsUser(BroadcastReceiver receiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1885 | UserHandle user, IntentFilter filter, @Nullable String broadcastPermission, |
| 1886 | @Nullable Handler scheduler); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1887 | |
| 1888 | /** |
| 1889 | * Unregister a previously registered BroadcastReceiver. <em>All</em> |
| 1890 | * filters that have been registered for this BroadcastReceiver will be |
| 1891 | * removed. |
| 1892 | * |
| 1893 | * @param receiver The BroadcastReceiver to unregister. |
| 1894 | * |
| 1895 | * @see #registerReceiver |
| 1896 | */ |
| 1897 | public abstract void unregisterReceiver(BroadcastReceiver receiver); |
| 1898 | |
| 1899 | /** |
| 1900 | * Request that a given application service be started. The Intent |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 1901 | * should contain either contain the complete class name of a specific service |
| 1902 | * implementation to start or a specific package name to target. If the |
Dianne Hackborn | 6bc3789 | 2013-10-03 11:05:14 -0700 | [diff] [blame] | 1903 | * Intent is less specified, it log a warning about this and which of the |
| 1904 | * multiple matching services it finds and uses will be undefined. If this service |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1905 | * is not already running, it will be instantiated and started (creating a |
| 1906 | * process for it if needed); if it is running then it remains running. |
| 1907 | * |
| 1908 | * <p>Every call to this method will result in a corresponding call to |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1909 | * the target service's {@link android.app.Service#onStartCommand} method, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1910 | * with the <var>intent</var> given here. This provides a convenient way |
| 1911 | * to submit jobs to a service without having to bind and call on to its |
| 1912 | * interface. |
| 1913 | * |
| 1914 | * <p>Using startService() overrides the default service lifetime that is |
| 1915 | * managed by {@link #bindService}: it requires the service to remain |
| 1916 | * running until {@link #stopService} is called, regardless of whether |
| 1917 | * any clients are connected to it. Note that calls to startService() |
| 1918 | * are not nesting: no matter how many times you call startService(), |
| 1919 | * a single call to {@link #stopService} will stop it. |
| 1920 | * |
| 1921 | * <p>The system attempts to keep running services around as much as |
| 1922 | * possible. The only time they should be stopped is if the current |
| 1923 | * foreground application is using so many resources that the service needs |
| 1924 | * to be killed. If any errors happen in the service's process, it will |
| 1925 | * automatically be restarted. |
| 1926 | * |
| 1927 | * <p>This function will throw {@link SecurityException} if you do not |
| 1928 | * have permission to start the given service. |
| 1929 | * |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 1930 | * @param service Identifies the service to be started. The Intent must be either |
| 1931 | * fully explicit (supplying a component name) or specify a specific package |
| 1932 | * name it is targetted to. Additional values |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1933 | * may be included in the Intent extras to supply arguments along with |
| 1934 | * this specific start call. |
| 1935 | * |
| 1936 | * @return If the service is being started or is already running, the |
| 1937 | * {@link ComponentName} of the actual service that was started is |
| 1938 | * returned; else if the service does not exist null is returned. |
| 1939 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1940 | * @throws SecurityException |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1941 | * |
| 1942 | * @see #stopService |
| 1943 | * @see #bindService |
| 1944 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1945 | @Nullable |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1946 | public abstract ComponentName startService(Intent service); |
| 1947 | |
| 1948 | /** |
| 1949 | * Request that a given application service be stopped. If the service is |
| 1950 | * not running, nothing happens. Otherwise it is stopped. Note that calls |
| 1951 | * to startService() are not counted -- this stops the service no matter |
| 1952 | * how many times it was started. |
| 1953 | * |
| 1954 | * <p>Note that if a stopped service still has {@link ServiceConnection} |
| 1955 | * objects bound to it with the {@link #BIND_AUTO_CREATE} set, it will |
| 1956 | * not be destroyed until all of these bindings are removed. See |
| 1957 | * the {@link android.app.Service} documentation for more details on a |
| 1958 | * service's lifecycle. |
| 1959 | * |
| 1960 | * <p>This function will throw {@link SecurityException} if you do not |
| 1961 | * have permission to stop the given service. |
| 1962 | * |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 1963 | * @param service Description of the service to be stopped. The Intent must be either |
| 1964 | * fully explicit (supplying a component name) or specify a specific package |
| 1965 | * name it is targetted to. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1966 | * |
| 1967 | * @return If there is a service matching the given Intent that is already |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1968 | * running, then it is stopped and {@code true} is returned; else {@code false} is returned. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1969 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1970 | * @throws SecurityException |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1971 | * |
| 1972 | * @see #startService |
| 1973 | */ |
| 1974 | public abstract boolean stopService(Intent service); |
| 1975 | |
| 1976 | /** |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 1977 | * @hide like {@link #startService(Intent)} but for a specific user. |
| 1978 | */ |
| 1979 | public abstract ComponentName startServiceAsUser(Intent service, UserHandle user); |
| 1980 | |
| 1981 | /** |
| 1982 | * @hide like {@link #stopService(Intent)} but for a specific user. |
| 1983 | */ |
| 1984 | public abstract boolean stopServiceAsUser(Intent service, UserHandle user); |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 1985 | |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 1986 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1987 | * Connect to an application service, creating it if needed. This defines |
| 1988 | * a dependency between your application and the service. The given |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 1989 | * <var>conn</var> will receive the service object when it is created and be |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1990 | * told if it dies and restarts. The service will be considered required |
| 1991 | * by the system only for as long as the calling context exists. For |
| 1992 | * example, if this Context is an Activity that is stopped, the service will |
| 1993 | * not be required to continue running until the Activity is resumed. |
| 1994 | * |
| 1995 | * <p>This function will throw {@link SecurityException} if you do not |
| 1996 | * have permission to bind to the given service. |
| 1997 | * |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 1998 | * <p class="note">Note: this method <em>can not be called from a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1999 | * {@link BroadcastReceiver} component</em>. A pattern you can use to |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2000 | * communicate from a BroadcastReceiver to a Service is to call |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2001 | * {@link #startService} with the arguments containing the command to be |
| 2002 | * sent, with the service calling its |
| 2003 | * {@link android.app.Service#stopSelf(int)} method when done executing |
| 2004 | * that command. See the API demo App/Service/Service Start Arguments |
| 2005 | * Controller for an illustration of this. It is okay, however, to use |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2006 | * this method from a BroadcastReceiver that has been registered with |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2007 | * {@link #registerReceiver}, since the lifetime of this BroadcastReceiver |
| 2008 | * is tied to another object (the one that registered it).</p> |
| 2009 | * |
| 2010 | * @param service Identifies the service to connect to. The Intent may |
| 2011 | * specify either an explicit component name, or a logical |
| 2012 | * description (action, category, etc) to match an |
| 2013 | * {@link IntentFilter} published by a service. |
| 2014 | * @param conn Receives information as the service is started and stopped. |
Christopher Tate | 79b3317 | 2012-06-18 14:54:21 -0700 | [diff] [blame] | 2015 | * This must be a valid ServiceConnection object; it must not be null. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2016 | * @param flags Operation options for the binding. May be 0, |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 2017 | * {@link #BIND_AUTO_CREATE}, {@link #BIND_DEBUG_UNBIND}, |
| 2018 | * {@link #BIND_NOT_FOREGROUND}, {@link #BIND_ABOVE_CLIENT}, |
| 2019 | * {@link #BIND_ALLOW_OOM_MANAGEMENT}, or |
| 2020 | * {@link #BIND_WAIVE_PRIORITY}. |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 2021 | * @return If you have successfully bound to the service, {@code true} is returned; |
| 2022 | * {@code false} is returned if the connection is not made so you will not |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2023 | * receive the service object. |
| 2024 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 2025 | * @throws SecurityException |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2026 | * |
| 2027 | * @see #unbindService |
| 2028 | * @see #startService |
| 2029 | * @see #BIND_AUTO_CREATE |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2030 | * @see #BIND_DEBUG_UNBIND |
| 2031 | * @see #BIND_NOT_FOREGROUND |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2032 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2033 | public abstract boolean bindService(Intent service, @NonNull ServiceConnection conn, |
| 2034 | @BindServiceFlags int flags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2035 | |
| 2036 | /** |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2037 | * Same as {@link #bindService(Intent, ServiceConnection, int)}, but with an explicit userHandle |
Amith Yamasani | 37ce3a8 | 2012-02-06 12:04:42 -0800 | [diff] [blame] | 2038 | * argument for use by system server and other multi-user aware code. |
| 2039 | * @hide |
| 2040 | */ |
Amith Yamasani | c85029f | 2014-09-11 16:47:17 -0700 | [diff] [blame] | 2041 | @SystemApi |
Amith Yamasani | 27b89e6 | 2013-01-16 12:30:11 -0800 | [diff] [blame] | 2042 | public boolean bindServiceAsUser(Intent service, ServiceConnection conn, int flags, UserHandle user) { |
Amith Yamasani | 37ce3a8 | 2012-02-06 12:04:42 -0800 | [diff] [blame] | 2043 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 2044 | } |
| 2045 | |
| 2046 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2047 | * Disconnect from an application service. You will no longer receive |
| 2048 | * calls as the service is restarted, and the service is now allowed to |
| 2049 | * stop at any time. |
| 2050 | * |
| 2051 | * @param conn The connection interface previously supplied to |
Christopher Tate | 79b3317 | 2012-06-18 14:54:21 -0700 | [diff] [blame] | 2052 | * bindService(). This parameter must not be null. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2053 | * |
| 2054 | * @see #bindService |
| 2055 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2056 | public abstract void unbindService(@NonNull ServiceConnection conn); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2057 | |
| 2058 | /** |
| 2059 | * Start executing an {@link android.app.Instrumentation} class. The given |
| 2060 | * Instrumentation component will be run by killing its target application |
| 2061 | * (if currently running), starting the target process, instantiating the |
| 2062 | * instrumentation component, and then letting it drive the application. |
| 2063 | * |
| 2064 | * <p>This function is not synchronous -- it returns as soon as the |
| 2065 | * instrumentation has started and while it is running. |
| 2066 | * |
| 2067 | * <p>Instrumentation is normally only allowed to run against a package |
| 2068 | * that is either unsigned or signed with a signature that the |
| 2069 | * the instrumentation package is also signed with (ensuring the target |
| 2070 | * trusts the instrumentation). |
| 2071 | * |
| 2072 | * @param className Name of the Instrumentation component to be run. |
| 2073 | * @param profileFile Optional path to write profiling data as the |
| 2074 | * instrumentation runs, or null for no profiling. |
| 2075 | * @param arguments Additional optional arguments to pass to the |
| 2076 | * instrumentation, or null. |
| 2077 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 2078 | * @return {@code true} if the instrumentation was successfully started, |
| 2079 | * else {@code false} if it could not be found. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2080 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2081 | public abstract boolean startInstrumentation(@NonNull ComponentName className, |
| 2082 | @Nullable String profileFile, @Nullable Bundle arguments); |
| 2083 | |
| 2084 | /** @hide */ |
| 2085 | @StringDef({ |
| 2086 | POWER_SERVICE, |
| 2087 | WINDOW_SERVICE, |
| 2088 | LAYOUT_INFLATER_SERVICE, |
| 2089 | ACCOUNT_SERVICE, |
| 2090 | ACTIVITY_SERVICE, |
| 2091 | ALARM_SERVICE, |
| 2092 | NOTIFICATION_SERVICE, |
| 2093 | ACCESSIBILITY_SERVICE, |
| 2094 | CAPTIONING_SERVICE, |
| 2095 | KEYGUARD_SERVICE, |
| 2096 | LOCATION_SERVICE, |
| 2097 | //@hide: COUNTRY_DETECTOR, |
| 2098 | SEARCH_SERVICE, |
| 2099 | SENSOR_SERVICE, |
| 2100 | STORAGE_SERVICE, |
| 2101 | WALLPAPER_SERVICE, |
| 2102 | VIBRATOR_SERVICE, |
| 2103 | //@hide: STATUS_BAR_SERVICE, |
| 2104 | CONNECTIVITY_SERVICE, |
| 2105 | //@hide: UPDATE_LOCK_SERVICE, |
| 2106 | //@hide: NETWORKMANAGEMENT_SERVICE, |
| 2107 | //@hide: NETWORK_STATS_SERVICE, |
| 2108 | //@hide: NETWORK_POLICY_SERVICE, |
| 2109 | WIFI_SERVICE, |
Yuhao Zheng | a486447 | 2014-04-10 11:45:42 -0700 | [diff] [blame] | 2110 | WIFI_PASSPOINT_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2111 | WIFI_P2P_SERVICE, |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 2112 | WIFI_SCANNING_SERVICE, |
Lorenzo Colitti | bd8a374 | 2014-05-22 11:51:27 -0700 | [diff] [blame] | 2113 | //@hide: ETHERNET_SERVICE, |
Vinit Deshpande | 7686c06 | 2014-06-30 15:25:01 -0700 | [diff] [blame] | 2114 | WIFI_RTT_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2115 | NSD_SERVICE, |
| 2116 | AUDIO_SERVICE, |
| 2117 | MEDIA_ROUTER_SERVICE, |
| 2118 | TELEPHONY_SERVICE, |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2119 | TELECOM_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2120 | CLIPBOARD_SERVICE, |
| 2121 | INPUT_METHOD_SERVICE, |
| 2122 | TEXT_SERVICES_MANAGER_SERVICE, |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 2123 | APPWIDGET_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2124 | //@hide: BACKUP_SERVICE, |
| 2125 | DROPBOX_SERVICE, |
| 2126 | DEVICE_POLICY_SERVICE, |
| 2127 | UI_MODE_SERVICE, |
| 2128 | DOWNLOAD_SERVICE, |
| 2129 | NFC_SERVICE, |
| 2130 | BLUETOOTH_SERVICE, |
| 2131 | //@hide: SIP_SERVICE, |
| 2132 | USB_SERVICE, |
Amith Yamasani | 4f58263 | 2014-02-19 14:31:52 -0800 | [diff] [blame] | 2133 | LAUNCHER_APPS_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2134 | //@hide: SERIAL_SERVICE, |
| 2135 | INPUT_SERVICE, |
| 2136 | DISPLAY_SERVICE, |
| 2137 | //@hide: SCHEDULING_POLICY_SERVICE, |
| 2138 | USER_SERVICE, |
| 2139 | //@hide: APP_OPS_SERVICE |
| 2140 | CAMERA_SERVICE, |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 2141 | PRINT_SERVICE, |
| 2142 | MEDIA_SESSION_SERVICE, |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 2143 | BATTERY_SERVICE, |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 2144 | JOB_SCHEDULER_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2145 | }) |
| 2146 | @Retention(RetentionPolicy.SOURCE) |
| 2147 | public @interface ServiceName {} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2148 | |
| 2149 | /** |
| 2150 | * Return the handle to a system-level service by name. The class of the |
| 2151 | * returned object varies by the requested name. Currently available names |
| 2152 | * are: |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2153 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2154 | * <dl> |
| 2155 | * <dt> {@link #WINDOW_SERVICE} ("window") |
| 2156 | * <dd> The top-level window manager in which you can place custom |
| 2157 | * windows. The returned object is a {@link android.view.WindowManager}. |
| 2158 | * <dt> {@link #LAYOUT_INFLATER_SERVICE} ("layout_inflater") |
| 2159 | * <dd> A {@link android.view.LayoutInflater} for inflating layout resources |
| 2160 | * in this context. |
| 2161 | * <dt> {@link #ACTIVITY_SERVICE} ("activity") |
| 2162 | * <dd> A {@link android.app.ActivityManager} for interacting with the |
| 2163 | * global activity state of the system. |
| 2164 | * <dt> {@link #POWER_SERVICE} ("power") |
| 2165 | * <dd> A {@link android.os.PowerManager} for controlling power |
| 2166 | * management. |
| 2167 | * <dt> {@link #ALARM_SERVICE} ("alarm") |
| 2168 | * <dd> A {@link android.app.AlarmManager} for receiving intents at the |
| 2169 | * time of your choosing. |
| 2170 | * <dt> {@link #NOTIFICATION_SERVICE} ("notification") |
| 2171 | * <dd> A {@link android.app.NotificationManager} for informing the user |
| 2172 | * of background events. |
| 2173 | * <dt> {@link #KEYGUARD_SERVICE} ("keyguard") |
| 2174 | * <dd> A {@link android.app.KeyguardManager} for controlling keyguard. |
| 2175 | * <dt> {@link #LOCATION_SERVICE} ("location") |
| 2176 | * <dd> A {@link android.location.LocationManager} for controlling location |
| 2177 | * (e.g., GPS) updates. |
| 2178 | * <dt> {@link #SEARCH_SERVICE} ("search") |
| 2179 | * <dd> A {@link android.app.SearchManager} for handling search. |
| 2180 | * <dt> {@link #VIBRATOR_SERVICE} ("vibrator") |
| 2181 | * <dd> A {@link android.os.Vibrator} for interacting with the vibrator |
| 2182 | * hardware. |
| 2183 | * <dt> {@link #CONNECTIVITY_SERVICE} ("connection") |
| 2184 | * <dd> A {@link android.net.ConnectivityManager ConnectivityManager} for |
| 2185 | * handling management of network connections. |
| 2186 | * <dt> {@link #WIFI_SERVICE} ("wifi") |
| 2187 | * <dd> A {@link android.net.wifi.WifiManager WifiManager} for management of |
| 2188 | * Wi-Fi connectivity. |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 2189 | * <dt> {@link #WIFI_P2P_SERVICE} ("wifip2p") |
| 2190 | * <dd> A {@link android.net.wifi.p2p.WifiP2pManager WifiP2pManager} for management of |
| 2191 | * Wi-Fi Direct connectivity. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2192 | * <dt> {@link #INPUT_METHOD_SERVICE} ("input_method") |
| 2193 | * <dd> An {@link android.view.inputmethod.InputMethodManager InputMethodManager} |
| 2194 | * for management of input methods. |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 2195 | * <dt> {@link #UI_MODE_SERVICE} ("uimode") |
| 2196 | * <dd> An {@link android.app.UiModeManager} for controlling UI modes. |
Steve Howard | 7083c42 | 2010-07-28 16:01:23 -0700 | [diff] [blame] | 2197 | * <dt> {@link #DOWNLOAD_SERVICE} ("download") |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 2198 | * <dd> A {@link android.app.DownloadManager} for requesting HTTP downloads |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 2199 | * <dt> {@link #BATTERY_SERVICE} ("batterymanager") |
Todd Poynor | 99f7e12 | 2014-04-15 16:03:42 -0700 | [diff] [blame] | 2200 | * <dd> A {@link android.os.BatteryManager} for managing battery state |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 2201 | * <dt> {@link #JOB_SCHEDULER_SERVICE} ("taskmanager") |
| 2202 | * <dd> A {@link android.app.job.JobScheduler} for managing scheduled tasks |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2203 | * </dl> |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2204 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2205 | * <p>Note: System services obtained via this API may be closely associated with |
| 2206 | * the Context in which they are obtained from. In general, do not share the |
| 2207 | * service objects between various different contexts (Activities, Applications, |
| 2208 | * Services, Providers, etc.) |
| 2209 | * |
| 2210 | * @param name The name of the desired service. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2211 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2212 | * @return The service or null if the name does not exist. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2213 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2214 | * @see #WINDOW_SERVICE |
| 2215 | * @see android.view.WindowManager |
| 2216 | * @see #LAYOUT_INFLATER_SERVICE |
| 2217 | * @see android.view.LayoutInflater |
| 2218 | * @see #ACTIVITY_SERVICE |
| 2219 | * @see android.app.ActivityManager |
| 2220 | * @see #POWER_SERVICE |
| 2221 | * @see android.os.PowerManager |
| 2222 | * @see #ALARM_SERVICE |
| 2223 | * @see android.app.AlarmManager |
| 2224 | * @see #NOTIFICATION_SERVICE |
| 2225 | * @see android.app.NotificationManager |
| 2226 | * @see #KEYGUARD_SERVICE |
| 2227 | * @see android.app.KeyguardManager |
| 2228 | * @see #LOCATION_SERVICE |
| 2229 | * @see android.location.LocationManager |
| 2230 | * @see #SEARCH_SERVICE |
| 2231 | * @see android.app.SearchManager |
| 2232 | * @see #SENSOR_SERVICE |
| 2233 | * @see android.hardware.SensorManager |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 2234 | * @see #STORAGE_SERVICE |
San Mehat | b104340 | 2010-02-05 08:26:50 -0800 | [diff] [blame] | 2235 | * @see android.os.storage.StorageManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2236 | * @see #VIBRATOR_SERVICE |
| 2237 | * @see android.os.Vibrator |
| 2238 | * @see #CONNECTIVITY_SERVICE |
| 2239 | * @see android.net.ConnectivityManager |
| 2240 | * @see #WIFI_SERVICE |
| 2241 | * @see android.net.wifi.WifiManager |
| 2242 | * @see #AUDIO_SERVICE |
| 2243 | * @see android.media.AudioManager |
Dianne Hackborn | b58b8f8 | 2012-06-11 15:08:39 -0700 | [diff] [blame] | 2244 | * @see #MEDIA_ROUTER_SERVICE |
| 2245 | * @see android.media.MediaRouter |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2246 | * @see #TELEPHONY_SERVICE |
| 2247 | * @see android.telephony.TelephonyManager |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame^] | 2248 | * @see #TELEPHONY_SUBSCRIPTION_SERVICE |
| 2249 | * @see android.telephony.SubscriptionManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2250 | * @see #INPUT_METHOD_SERVICE |
| 2251 | * @see android.view.inputmethod.InputMethodManager |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 2252 | * @see #UI_MODE_SERVICE |
| 2253 | * @see android.app.UiModeManager |
Steve Howard | 7083c42 | 2010-07-28 16:01:23 -0700 | [diff] [blame] | 2254 | * @see #DOWNLOAD_SERVICE |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 2255 | * @see android.app.DownloadManager |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 2256 | * @see #BATTERY_SERVICE |
| 2257 | * @see android.os.BatteryManager |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 2258 | * @see #JOB_SCHEDULER_SERVICE |
| 2259 | * @see android.app.job.JobScheduler |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2260 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2261 | public abstract Object getSystemService(@ServiceName @NonNull String name); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2262 | |
| 2263 | /** |
| 2264 | * Use with {@link #getSystemService} to retrieve a |
| 2265 | * {@link android.os.PowerManager} for controlling power management, |
| 2266 | * including "wake locks," which let you keep the device on while |
| 2267 | * you're running long tasks. |
| 2268 | */ |
| 2269 | public static final String POWER_SERVICE = "power"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2270 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2271 | /** |
| 2272 | * Use with {@link #getSystemService} to retrieve a |
| 2273 | * {@link android.view.WindowManager} for accessing the system's window |
| 2274 | * manager. |
| 2275 | * |
| 2276 | * @see #getSystemService |
| 2277 | * @see android.view.WindowManager |
| 2278 | */ |
| 2279 | public static final String WINDOW_SERVICE = "window"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2280 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2281 | /** |
| 2282 | * Use with {@link #getSystemService} to retrieve a |
| 2283 | * {@link android.view.LayoutInflater} for inflating layout resources in this |
| 2284 | * context. |
| 2285 | * |
| 2286 | * @see #getSystemService |
| 2287 | * @see android.view.LayoutInflater |
| 2288 | */ |
| 2289 | public static final String LAYOUT_INFLATER_SERVICE = "layout_inflater"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2290 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2291 | /** |
| 2292 | * Use with {@link #getSystemService} to retrieve a |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 2293 | * {@link android.accounts.AccountManager} for receiving intents at a |
| 2294 | * time of your choosing. |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 2295 | * |
| 2296 | * @see #getSystemService |
| 2297 | * @see android.accounts.AccountManager |
| 2298 | */ |
| 2299 | public static final String ACCOUNT_SERVICE = "account"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2300 | |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 2301 | /** |
| 2302 | * Use with {@link #getSystemService} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2303 | * {@link android.app.ActivityManager} for interacting with the global |
| 2304 | * system state. |
| 2305 | * |
| 2306 | * @see #getSystemService |
| 2307 | * @see android.app.ActivityManager |
| 2308 | */ |
| 2309 | public static final String ACTIVITY_SERVICE = "activity"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2310 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2311 | /** |
| 2312 | * Use with {@link #getSystemService} to retrieve a |
| 2313 | * {@link android.app.AlarmManager} for receiving intents at a |
| 2314 | * time of your choosing. |
| 2315 | * |
| 2316 | * @see #getSystemService |
| 2317 | * @see android.app.AlarmManager |
| 2318 | */ |
| 2319 | public static final String ALARM_SERVICE = "alarm"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2320 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2321 | /** |
| 2322 | * Use with {@link #getSystemService} to retrieve a |
| 2323 | * {@link android.app.NotificationManager} for informing the user of |
| 2324 | * background events. |
| 2325 | * |
| 2326 | * @see #getSystemService |
| 2327 | * @see android.app.NotificationManager |
| 2328 | */ |
| 2329 | public static final String NOTIFICATION_SERVICE = "notification"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2330 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2331 | /** |
| 2332 | * Use with {@link #getSystemService} to retrieve a |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 2333 | * {@link android.view.accessibility.AccessibilityManager} for giving the user |
| 2334 | * feedback for UI events through the registered event listeners. |
| 2335 | * |
| 2336 | * @see #getSystemService |
| 2337 | * @see android.view.accessibility.AccessibilityManager |
| 2338 | */ |
| 2339 | public static final String ACCESSIBILITY_SERVICE = "accessibility"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2340 | |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 2341 | /** |
| 2342 | * Use with {@link #getSystemService} to retrieve a |
Alan Viverette | 69ce69b | 2013-08-29 12:23:48 -0700 | [diff] [blame] | 2343 | * {@link android.view.accessibility.CaptioningManager} for obtaining |
| 2344 | * captioning properties and listening for changes in captioning |
| 2345 | * preferences. |
| 2346 | * |
| 2347 | * @see #getSystemService |
| 2348 | * @see android.view.accessibility.CaptioningManager |
| 2349 | */ |
| 2350 | public static final String CAPTIONING_SERVICE = "captioning"; |
| 2351 | |
| 2352 | /** |
| 2353 | * Use with {@link #getSystemService} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2354 | * {@link android.app.NotificationManager} for controlling keyguard. |
| 2355 | * |
| 2356 | * @see #getSystemService |
| 2357 | * @see android.app.KeyguardManager |
| 2358 | */ |
| 2359 | public static final String KEYGUARD_SERVICE = "keyguard"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2360 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2361 | /** |
| 2362 | * Use with {@link #getSystemService} to retrieve a {@link |
| 2363 | * android.location.LocationManager} for controlling location |
| 2364 | * updates. |
| 2365 | * |
| 2366 | * @see #getSystemService |
| 2367 | * @see android.location.LocationManager |
| 2368 | */ |
| 2369 | public static final String LOCATION_SERVICE = "location"; |
Bai Tao | a58a875 | 2010-07-13 15:32:16 +0800 | [diff] [blame] | 2370 | |
| 2371 | /** |
| 2372 | * Use with {@link #getSystemService} to retrieve a |
| 2373 | * {@link android.location.CountryDetector} for detecting the country that |
| 2374 | * the user is in. |
| 2375 | * |
| 2376 | * @hide |
| 2377 | */ |
| 2378 | public static final String COUNTRY_DETECTOR = "country_detector"; |
| 2379 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2380 | /** |
| 2381 | * Use with {@link #getSystemService} to retrieve a {@link |
| 2382 | * android.app.SearchManager} for handling searches. |
| 2383 | * |
| 2384 | * @see #getSystemService |
| 2385 | * @see android.app.SearchManager |
| 2386 | */ |
| 2387 | public static final String SEARCH_SERVICE = "search"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2388 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2389 | /** |
| 2390 | * Use with {@link #getSystemService} to retrieve a {@link |
| 2391 | * android.hardware.SensorManager} for accessing sensors. |
| 2392 | * |
| 2393 | * @see #getSystemService |
| 2394 | * @see android.hardware.SensorManager |
| 2395 | */ |
| 2396 | public static final String SENSOR_SERVICE = "sensor"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2397 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2398 | /** |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 2399 | * Use with {@link #getSystemService} to retrieve a {@link |
Kenny Root | 02c8730 | 2010-07-01 08:10:18 -0700 | [diff] [blame] | 2400 | * android.os.storage.StorageManager} for accessing system storage |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 2401 | * functions. |
| 2402 | * |
| 2403 | * @see #getSystemService |
San Mehat | b104340 | 2010-02-05 08:26:50 -0800 | [diff] [blame] | 2404 | * @see android.os.storage.StorageManager |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 2405 | */ |
| 2406 | public static final String STORAGE_SERVICE = "storage"; |
| 2407 | |
| 2408 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2409 | * Use with {@link #getSystemService} to retrieve a |
| 2410 | * com.android.server.WallpaperService for accessing wallpapers. |
| 2411 | * |
| 2412 | * @see #getSystemService |
| 2413 | */ |
| 2414 | public static final String WALLPAPER_SERVICE = "wallpaper"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2415 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2416 | /** |
| 2417 | * Use with {@link #getSystemService} to retrieve a {@link |
| 2418 | * android.os.Vibrator} for interacting with the vibration hardware. |
| 2419 | * |
| 2420 | * @see #getSystemService |
| 2421 | * @see android.os.Vibrator |
| 2422 | */ |
| 2423 | public static final String VIBRATOR_SERVICE = "vibrator"; |
Robert Greenwalt | 9e696c2 | 2010-04-01 14:45:18 -0700 | [diff] [blame] | 2424 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2425 | /** |
| 2426 | * Use with {@link #getSystemService} to retrieve a {@link |
| 2427 | * android.app.StatusBarManager} for interacting with the status bar. |
| 2428 | * |
| 2429 | * @see #getSystemService |
| 2430 | * @see android.app.StatusBarManager |
| 2431 | * @hide |
| 2432 | */ |
| 2433 | public static final String STATUS_BAR_SERVICE = "statusbar"; |
| 2434 | |
| 2435 | /** |
| 2436 | * Use with {@link #getSystemService} to retrieve a {@link |
| 2437 | * android.net.ConnectivityManager} for handling management of |
| 2438 | * network connections. |
| 2439 | * |
| 2440 | * @see #getSystemService |
| 2441 | * @see android.net.ConnectivityManager |
| 2442 | */ |
| 2443 | public static final String CONNECTIVITY_SERVICE = "connectivity"; |
| 2444 | |
| 2445 | /** |
| 2446 | * Use with {@link #getSystemService} to retrieve a {@link |
Christopher Tate | 8662cab5 | 2012-02-23 14:59:36 -0800 | [diff] [blame] | 2447 | * android.os.IUpdateLock} for managing runtime sequences that |
| 2448 | * must not be interrupted by headless OTA application or similar. |
| 2449 | * |
| 2450 | * @hide |
| 2451 | * @see #getSystemService |
| 2452 | * @see android.os.UpdateLock |
| 2453 | */ |
| 2454 | public static final String UPDATE_LOCK_SERVICE = "updatelock"; |
| 2455 | |
| 2456 | /** |
Dianne Hackborn | 35f72be | 2013-09-16 10:57:39 -0700 | [diff] [blame] | 2457 | * Constant for the internal network management service, not really a Context service. |
Dianne Hackborn | 0a6a80f | 2013-09-16 15:20:27 -0700 | [diff] [blame] | 2458 | * @hide |
San Mehat | d1df8ac | 2010-01-26 06:17:26 -0800 | [diff] [blame] | 2459 | */ |
| 2460 | public static final String NETWORKMANAGEMENT_SERVICE = "network_management"; |
| 2461 | |
Jeff Sharkey | eedcb95 | 2011-05-17 14:55:15 -0700 | [diff] [blame] | 2462 | /** {@hide} */ |
Jeff Sharkey | 7527990 | 2011-05-24 18:39:45 -0700 | [diff] [blame] | 2463 | public static final String NETWORK_STATS_SERVICE = "netstats"; |
| 2464 | /** {@hide} */ |
Jeff Sharkey | eedcb95 | 2011-05-17 14:55:15 -0700 | [diff] [blame] | 2465 | public static final String NETWORK_POLICY_SERVICE = "netpolicy"; |
| 2466 | |
San Mehat | d1df8ac | 2010-01-26 06:17:26 -0800 | [diff] [blame] | 2467 | /** |
| 2468 | * Use with {@link #getSystemService} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2469 | * android.net.wifi.WifiManager} for handling management of |
| 2470 | * Wi-Fi access. |
| 2471 | * |
| 2472 | * @see #getSystemService |
| 2473 | * @see android.net.wifi.WifiManager |
| 2474 | */ |
| 2475 | public static final String WIFI_SERVICE = "wifi"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2476 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2477 | /** |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 2478 | * Use with {@link #getSystemService} to retrieve a {@link |
Roger Chang | 7fee723 | 2014-05-15 14:46:49 -0700 | [diff] [blame] | 2479 | * android.net.wifi.passpoint.WifiPasspointManager} for handling management of |
Yuhao Zheng | a486447 | 2014-04-10 11:45:42 -0700 | [diff] [blame] | 2480 | * Wi-Fi passpoint access. |
Yuhao Zheng | 10bf635 | 2014-03-25 15:00:45 -0700 | [diff] [blame] | 2481 | * |
| 2482 | * @see #getSystemService |
Roger Chang | 7fee723 | 2014-05-15 14:46:49 -0700 | [diff] [blame] | 2483 | * @see android.net.wifi.passpoint.WifiPasspointManager |
Yuhao Zheng | 0cb59f2 | 2014-05-27 10:35:02 -0700 | [diff] [blame] | 2484 | * @hide |
Yuhao Zheng | 10bf635 | 2014-03-25 15:00:45 -0700 | [diff] [blame] | 2485 | */ |
Yuhao Zheng | a486447 | 2014-04-10 11:45:42 -0700 | [diff] [blame] | 2486 | public static final String WIFI_PASSPOINT_SERVICE = "wifipasspoint"; |
Yuhao Zheng | 10bf635 | 2014-03-25 15:00:45 -0700 | [diff] [blame] | 2487 | |
| 2488 | /** |
| 2489 | * Use with {@link #getSystemService} to retrieve a {@link |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 2490 | * android.net.wifi.p2p.WifiP2pManager} for handling management of |
Irfan Sheriff | 651cdfc | 2011-09-07 00:31:20 -0700 | [diff] [blame] | 2491 | * Wi-Fi peer-to-peer connections. |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 2492 | * |
| 2493 | * @see #getSystemService |
| 2494 | * @see android.net.wifi.p2p.WifiP2pManager |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 2495 | */ |
| 2496 | public static final String WIFI_P2P_SERVICE = "wifip2p"; |
| 2497 | |
| 2498 | /** |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 2499 | * Use with {@link #getSystemService} to retrieve a {@link |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 2500 | * android.net.wifi.WifiScanner} for scanning the wifi universe |
| 2501 | * |
| 2502 | * @see #getSystemService |
| 2503 | * @see android.net.wifi.WifiScanner |
| 2504 | * @hide |
| 2505 | */ |
Wei Wang | 35d552f | 2014-07-08 21:37:01 -0700 | [diff] [blame] | 2506 | @SystemApi |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 2507 | public static final String WIFI_SCANNING_SERVICE = "wifiscanner"; |
| 2508 | |
| 2509 | /** |
| 2510 | * Use with {@link #getSystemService} to retrieve a {@link |
Vinit Deshpande | 7686c06 | 2014-06-30 15:25:01 -0700 | [diff] [blame] | 2511 | * android.net.wifi.RttManager} for ranging devices with wifi |
| 2512 | * |
| 2513 | * @see #getSystemService |
| 2514 | * @see android.net.wifi.RttManager |
| 2515 | * @hide |
| 2516 | */ |
| 2517 | @SystemApi |
| 2518 | public static final String WIFI_RTT_SERVICE = "rttmanager"; |
| 2519 | |
| 2520 | /** |
| 2521 | * Use with {@link #getSystemService} to retrieve a {@link |
Dianne Hackborn | fee756f | 2014-07-16 17:31:10 -0700 | [diff] [blame] | 2522 | * android.net.EthernetManager} for handling management of |
Lorenzo Colitti | f9ff2c9 | 2014-05-21 16:32:11 -0700 | [diff] [blame] | 2523 | * Ethernet access. |
| 2524 | * |
| 2525 | * @see #getSystemService |
Dianne Hackborn | fee756f | 2014-07-16 17:31:10 -0700 | [diff] [blame] | 2526 | * @see android.net.EthernetManager |
Lorenzo Colitti | f9ff2c9 | 2014-05-21 16:32:11 -0700 | [diff] [blame] | 2527 | * |
| 2528 | * @hide |
| 2529 | */ |
| 2530 | public static final String ETHERNET_SERVICE = "ethernet"; |
| 2531 | |
| 2532 | /** |
| 2533 | * Use with {@link #getSystemService} to retrieve a {@link |
Irfan Sheriff | 60309fc | 2012-04-24 14:52:37 -0700 | [diff] [blame] | 2534 | * android.net.nsd.NsdManager} for handling management of network service |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 2535 | * discovery |
| 2536 | * |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 2537 | * @see #getSystemService |
Irfan Sheriff | 60309fc | 2012-04-24 14:52:37 -0700 | [diff] [blame] | 2538 | * @see android.net.nsd.NsdManager |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 2539 | */ |
| 2540 | public static final String NSD_SERVICE = "servicediscovery"; |
| 2541 | |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 2542 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2543 | * Use with {@link #getSystemService} to retrieve a |
| 2544 | * {@link android.media.AudioManager} for handling management of volume, |
| 2545 | * ringer modes and audio routing. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2546 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2547 | * @see #getSystemService |
| 2548 | * @see android.media.AudioManager |
| 2549 | */ |
| 2550 | public static final String AUDIO_SERVICE = "audio"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2551 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2552 | /** |
| 2553 | * Use with {@link #getSystemService} to retrieve a |
Jim Miller | 08fa40c | 2014-04-29 18:18:47 -0700 | [diff] [blame] | 2554 | * {@link android.service.fingerprint.FingerprintManager} for handling management |
| 2555 | * of fingerprints. |
| 2556 | * |
| 2557 | * @see #getSystemService |
| 2558 | * @see android.app.FingerprintManager |
Jim Miller | 777f5b2 | 2014-08-25 15:03:50 -0700 | [diff] [blame] | 2559 | * @hide |
Jim Miller | 08fa40c | 2014-04-29 18:18:47 -0700 | [diff] [blame] | 2560 | */ |
| 2561 | public static final String FINGERPRINT_SERVICE = "fingerprint"; |
| 2562 | |
| 2563 | /** |
| 2564 | * Use with {@link #getSystemService} to retrieve a |
Dianne Hackborn | b58b8f8 | 2012-06-11 15:08:39 -0700 | [diff] [blame] | 2565 | * {@link android.media.MediaRouter} for controlling and managing |
| 2566 | * routing of media. |
| 2567 | * |
| 2568 | * @see #getSystemService |
| 2569 | * @see android.media.MediaRouter |
| 2570 | */ |
| 2571 | public static final String MEDIA_ROUTER_SERVICE = "media_router"; |
| 2572 | |
| 2573 | /** |
| 2574 | * Use with {@link #getSystemService} to retrieve a |
RoboErik | 42ea7ee | 2014-05-16 16:27:35 -0700 | [diff] [blame] | 2575 | * {@link android.media.session.MediaSessionManager} for managing media Sessions. |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 2576 | * |
| 2577 | * @see #getSystemService |
RoboErik | 42ea7ee | 2014-05-16 16:27:35 -0700 | [diff] [blame] | 2578 | * @see android.media.session.MediaSessionManager |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 2579 | */ |
| 2580 | public static final String MEDIA_SESSION_SERVICE = "media_session"; |
| 2581 | |
| 2582 | /** |
| 2583 | * Use with {@link #getSystemService} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2584 | * {@link android.telephony.TelephonyManager} for handling management the |
| 2585 | * telephony features of the device. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2586 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2587 | * @see #getSystemService |
| 2588 | * @see android.telephony.TelephonyManager |
| 2589 | */ |
| 2590 | public static final String TELEPHONY_SERVICE = "phone"; |
| 2591 | |
| 2592 | /** |
| 2593 | * Use with {@link #getSystemService} to retrieve a |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame^] | 2594 | * {@link android.telephony.SubscriptionManager} for handling management the |
| 2595 | * telephony subscriptions of the device. |
| 2596 | * |
| 2597 | * @see #getSystemService |
| 2598 | * @see android.telephony.SubscriptionManager |
| 2599 | */ |
| 2600 | public static final String TELEPHONY_SUBSCRIPTION_SERVICE = "telephony_subscription_service"; |
| 2601 | |
| 2602 | /** |
| 2603 | * Use with {@link #getSystemService} to retrieve a |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2604 | * {@link android.telecom.TelecomManager} to manage telecom-related features |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 2605 | * of the device. |
| 2606 | * |
| 2607 | * @see #getSystemService |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2608 | * @see android.telecom.TelecomManager |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 2609 | */ |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2610 | public static final String TELECOM_SERVICE = "telecom"; |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 2611 | |
| 2612 | /** |
| 2613 | * Use with {@link #getSystemService} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2614 | * {@link android.text.ClipboardManager} for accessing and modifying |
| 2615 | * the contents of the global clipboard. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2616 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2617 | * @see #getSystemService |
| 2618 | * @see android.text.ClipboardManager |
| 2619 | */ |
| 2620 | public static final String CLIPBOARD_SERVICE = "clipboard"; |
| 2621 | |
| 2622 | /** |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2623 | * Use with {@link #getSystemService} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2624 | * {@link android.view.inputmethod.InputMethodManager} for accessing input |
| 2625 | * methods. |
| 2626 | * |
| 2627 | * @see #getSystemService |
| 2628 | */ |
| 2629 | public static final String INPUT_METHOD_SERVICE = "input_method"; |
| 2630 | |
| 2631 | /** |
| 2632 | * Use with {@link #getSystemService} to retrieve a |
satok | 988323c | 2011-06-22 16:38:13 +0900 | [diff] [blame] | 2633 | * {@link android.view.textservice.TextServicesManager} for accessing |
| 2634 | * text services. |
| 2635 | * |
| 2636 | * @see #getSystemService |
| 2637 | */ |
| 2638 | public static final String TEXT_SERVICES_MANAGER_SERVICE = "textservices"; |
| 2639 | |
| 2640 | /** |
| 2641 | * Use with {@link #getSystemService} to retrieve a |
Dan Egnor | e38d58b | 2009-12-30 19:29:03 -0800 | [diff] [blame] | 2642 | * {@link android.appwidget.AppWidgetManager} for accessing AppWidgets. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2643 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2644 | * @see #getSystemService |
| 2645 | */ |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 2646 | public static final String APPWIDGET_SERVICE = "appwidget"; |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 2647 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2648 | /** |
Dianne Hackborn | 91097de | 2014-04-04 18:02:06 -0700 | [diff] [blame] | 2649 | * Official published name of the (internal) voice interaction manager service. |
| 2650 | * |
| 2651 | * @hide |
| 2652 | * @see #getSystemService |
| 2653 | */ |
| 2654 | public static final String VOICE_INTERACTION_MANAGER_SERVICE = "voiceinteraction"; |
| 2655 | |
| 2656 | /** |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 2657 | * Use with {@link #getSystemService} to retrieve an |
Christopher Tate | 4528186 | 2010-03-05 15:46:30 -0800 | [diff] [blame] | 2658 | * {@link android.app.backup.IBackupManager IBackupManager} for communicating |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 2659 | * with the backup mechanism. |
Dianne Hackborn | 7f20543 | 2009-07-28 00:13:47 -0700 | [diff] [blame] | 2660 | * @hide |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2661 | * |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 2662 | * @see #getSystemService |
| 2663 | */ |
Christopher Tate | d5cf722 | 2014-07-29 16:53:09 -0700 | [diff] [blame] | 2664 | @SystemApi |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 2665 | public static final String BACKUP_SERVICE = "backup"; |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 2666 | |
| 2667 | /** |
| 2668 | * Use with {@link #getSystemService} to retrieve a |
Dan Egnor | 1337b01 | 2010-01-04 11:01:44 -0800 | [diff] [blame] | 2669 | * {@link android.os.DropBoxManager} instance for recording |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 2670 | * diagnostic logs. |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 2671 | * @see #getSystemService |
| 2672 | */ |
| 2673 | public static final String DROPBOX_SERVICE = "dropbox"; |
| 2674 | |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 2675 | /** |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2676 | * Use with {@link #getSystemService} to retrieve a |
Dianne Hackborn | 87bba1e | 2010-02-26 17:25:54 -0800 | [diff] [blame] | 2677 | * {@link android.app.admin.DevicePolicyManager} for working with global |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2678 | * device policy management. |
| 2679 | * |
| 2680 | * @see #getSystemService |
| 2681 | */ |
| 2682 | public static final String DEVICE_POLICY_SERVICE = "device_policy"; |
| 2683 | |
| 2684 | /** |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 2685 | * Use with {@link #getSystemService} to retrieve a |
| 2686 | * {@link android.app.UiModeManager} for controlling UI modes. |
| 2687 | * |
| 2688 | * @see #getSystemService |
| 2689 | */ |
| 2690 | public static final String UI_MODE_SERVICE = "uimode"; |
| 2691 | |
| 2692 | /** |
Steve Howard | a270936 | 2010-07-02 17:12:48 -0700 | [diff] [blame] | 2693 | * Use with {@link #getSystemService} to retrieve a |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 2694 | * {@link android.app.DownloadManager} for requesting HTTP downloads. |
Steve Howard | a270936 | 2010-07-02 17:12:48 -0700 | [diff] [blame] | 2695 | * |
| 2696 | * @see #getSystemService |
Steve Howard | a270936 | 2010-07-02 17:12:48 -0700 | [diff] [blame] | 2697 | */ |
| 2698 | public static final String DOWNLOAD_SERVICE = "download"; |
| 2699 | |
| 2700 | /** |
Chung-yih Wang | 2d94231 | 2010-08-05 12:17:37 +0800 | [diff] [blame] | 2701 | * Use with {@link #getSystemService} to retrieve a |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 2702 | * {@link android.os.BatteryManager} for managing battery state. |
| 2703 | * |
| 2704 | * @see #getSystemService |
| 2705 | */ |
| 2706 | public static final String BATTERY_SERVICE = "batterymanager"; |
| 2707 | |
| 2708 | /** |
| 2709 | * Use with {@link #getSystemService} to retrieve a |
Nick Pelly | 50b4d8f | 2010-12-07 22:40:28 -0800 | [diff] [blame] | 2710 | * {@link android.nfc.NfcManager} for using NFC. |
| 2711 | * |
| 2712 | * @see #getSystemService |
| 2713 | */ |
| 2714 | public static final String NFC_SERVICE = "nfc"; |
| 2715 | |
| 2716 | /** |
| 2717 | * Use with {@link #getSystemService} to retrieve a |
Jaikumar Ganesh | 1abb1cb | 2012-01-25 16:14:50 -0800 | [diff] [blame] | 2718 | * {@link android.bluetooth.BluetoothAdapter} for using Bluetooth. |
| 2719 | * |
| 2720 | * @see #getSystemService |
Jaikumar Ganesh | 1abb1cb | 2012-01-25 16:14:50 -0800 | [diff] [blame] | 2721 | */ |
| 2722 | public static final String BLUETOOTH_SERVICE = "bluetooth"; |
| 2723 | |
| 2724 | /** |
| 2725 | * Use with {@link #getSystemService} to retrieve a |
Chung-yih Wang | 2d94231 | 2010-08-05 12:17:37 +0800 | [diff] [blame] | 2726 | * {@link android.net.sip.SipManager} for accessing the SIP related service. |
| 2727 | * |
| 2728 | * @see #getSystemService |
| 2729 | */ |
| 2730 | /** @hide */ |
| 2731 | public static final String SIP_SERVICE = "sip"; |
| 2732 | |
| 2733 | /** |
Mike Lockwood | e7d511e | 2010-12-30 13:39:37 -0500 | [diff] [blame] | 2734 | * Use with {@link #getSystemService} to retrieve a {@link |
Mike Lockwood | c4308f0 | 2011-03-01 08:04:54 -0800 | [diff] [blame] | 2735 | * android.hardware.usb.UsbManager} for access to USB devices (as a USB host) |
Mike Lockwood | e7d511e | 2010-12-30 13:39:37 -0500 | [diff] [blame] | 2736 | * and for controlling this device's behavior as a USB device. |
| 2737 | * |
| 2738 | * @see #getSystemService |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 2739 | * @see android.hardware.usb.UsbManager |
Mike Lockwood | e7d511e | 2010-12-30 13:39:37 -0500 | [diff] [blame] | 2740 | */ |
| 2741 | public static final String USB_SERVICE = "usb"; |
| 2742 | |
| 2743 | /** |
Mike Lockwood | b01e8bf | 2011-08-29 20:11:07 -0400 | [diff] [blame] | 2744 | * Use with {@link #getSystemService} to retrieve a {@link |
| 2745 | * android.hardware.SerialManager} for access to serial ports. |
| 2746 | * |
| 2747 | * @see #getSystemService |
Dianne Hackborn | 35f72be | 2013-09-16 10:57:39 -0700 | [diff] [blame] | 2748 | * @see android.hardware.SerialManager |
Mike Lockwood | b01e8bf | 2011-08-29 20:11:07 -0400 | [diff] [blame] | 2749 | * |
| 2750 | * @hide |
| 2751 | */ |
| 2752 | public static final String SERIAL_SERVICE = "serial"; |
| 2753 | |
| 2754 | /** |
Jeff Brown | 9df6e7a | 2012-04-05 11:49:26 -0700 | [diff] [blame] | 2755 | * Use with {@link #getSystemService} to retrieve a |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 2756 | * {@link android.hardware.hdmi.HdmiControlManager} for controlling and managing |
| 2757 | * HDMI-CEC protocol. |
| 2758 | * |
| 2759 | * @see #getSystemService |
| 2760 | * @see android.hardware.hdmi.HdmiControlManager |
Jinsuk Kim | 66d1eb2 | 2014-06-06 16:12:18 +0900 | [diff] [blame] | 2761 | * @hide |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 2762 | */ |
Jinsuk Kim | 66d1eb2 | 2014-06-06 16:12:18 +0900 | [diff] [blame] | 2763 | @SystemApi |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 2764 | public static final String HDMI_CONTROL_SERVICE = "hdmi_control"; |
Jinsuk Kim | fbcd503 | 2014-03-21 16:25:13 +0900 | [diff] [blame] | 2765 | |
| 2766 | /** |
| 2767 | * Use with {@link #getSystemService} to retrieve a |
Jeff Brown | 9df6e7a | 2012-04-05 11:49:26 -0700 | [diff] [blame] | 2768 | * {@link android.hardware.input.InputManager} for interacting with input devices. |
| 2769 | * |
| 2770 | * @see #getSystemService |
| 2771 | * @see android.hardware.input.InputManager |
| 2772 | */ |
| 2773 | public static final String INPUT_SERVICE = "input"; |
| 2774 | |
| 2775 | /** |
Glenn Kasten | 07b0465 | 2012-04-23 15:00:43 -0700 | [diff] [blame] | 2776 | * Use with {@link #getSystemService} to retrieve a |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 2777 | * {@link android.hardware.display.DisplayManager} for interacting with display devices. |
| 2778 | * |
| 2779 | * @see #getSystemService |
| 2780 | * @see android.hardware.display.DisplayManager |
| 2781 | */ |
| 2782 | public static final String DISPLAY_SERVICE = "display"; |
| 2783 | |
| 2784 | /** |
| 2785 | * Use with {@link #getSystemService} to retrieve a |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 2786 | * {@link android.os.UserManager} for managing users on devices that support multiple users. |
| 2787 | * |
| 2788 | * @see #getSystemService |
| 2789 | * @see android.os.UserManager |
| 2790 | */ |
| 2791 | public static final String USER_SERVICE = "user"; |
| 2792 | |
| 2793 | /** |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 2794 | * Use with {@link #getSystemService} to retrieve a |
Amith Yamasani | 4f58263 | 2014-02-19 14:31:52 -0800 | [diff] [blame] | 2795 | * {@link android.content.pm.LauncherApps} for querying and monitoring launchable apps across |
| 2796 | * profiles of a user. |
| 2797 | * |
| 2798 | * @see #getSystemService |
| 2799 | * @see android.content.pm.LauncherApps |
| 2800 | */ |
| 2801 | public static final String LAUNCHER_APPS_SERVICE = "launcherapps"; |
| 2802 | |
| 2803 | /** |
| 2804 | * Use with {@link #getSystemService} to retrieve a |
Amith Yamasani | f20d640 | 2014-05-24 15:34:37 -0700 | [diff] [blame] | 2805 | * {@link android.content.RestrictionsManager} for retrieving application restrictions |
| 2806 | * and requesting permissions for restricted operations. |
| 2807 | * @see #getSystemService |
| 2808 | * @see android.content.RestrictionsManager |
| 2809 | */ |
| 2810 | public static final String RESTRICTIONS_SERVICE = "restrictions"; |
| 2811 | |
| 2812 | /** |
| 2813 | * Use with {@link #getSystemService} to retrieve a |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 2814 | * {@link android.app.AppOpsManager} for tracking application operations |
| 2815 | * on the device. |
| 2816 | * |
| 2817 | * @see #getSystemService |
| 2818 | * @see android.app.AppOpsManager |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 2819 | */ |
| 2820 | public static final String APP_OPS_SERVICE = "appops"; |
| 2821 | |
| 2822 | /** |
Eino-Ville Talvala | b267554 | 2012-12-12 13:29:45 -0800 | [diff] [blame] | 2823 | * Use with {@link #getSystemService} to retrieve a |
Eino-Ville Talvala | 2f1a2e4 | 2013-07-25 17:12:05 -0700 | [diff] [blame] | 2824 | * {@link android.hardware.camera2.CameraManager} for interacting with |
Eino-Ville Talvala | b267554 | 2012-12-12 13:29:45 -0800 | [diff] [blame] | 2825 | * camera devices. |
| 2826 | * |
| 2827 | * @see #getSystemService |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 2828 | * @see android.hardware.camera2.CameraManager |
Eino-Ville Talvala | b267554 | 2012-12-12 13:29:45 -0800 | [diff] [blame] | 2829 | */ |
| 2830 | public static final String CAMERA_SERVICE = "camera"; |
| 2831 | |
| 2832 | /** |
Svetoslav Ganov | 4b9a4d1 | 2013-06-11 15:20:06 -0700 | [diff] [blame] | 2833 | * {@link android.print.PrintManager} for printing and managing |
Jeff Brown | 511cd35 | 2013-08-23 17:43:37 -0700 | [diff] [blame] | 2834 | * printers and print tasks. |
Svetoslav Ganov | 4b9a4d1 | 2013-06-11 15:20:06 -0700 | [diff] [blame] | 2835 | * |
| 2836 | * @see #getSystemService |
| 2837 | * @see android.print.PrintManager |
| 2838 | */ |
| 2839 | public static final String PRINT_SERVICE = "print"; |
| 2840 | |
| 2841 | /** |
Erik Gilling | 51e95df | 2013-06-26 11:06:51 -0700 | [diff] [blame] | 2842 | * Use with {@link #getSystemService} to retrieve a |
| 2843 | * {@link android.hardware.ConsumerIrManager} for transmitting infrared |
| 2844 | * signals from the device. |
| 2845 | * |
| 2846 | * @see #getSystemService |
| 2847 | * @see android.hardware.ConsumerIrManager |
| 2848 | */ |
| 2849 | public static final String CONSUMER_IR_SERVICE = "consumer_ir"; |
| 2850 | |
| 2851 | /** |
Adrian Roos | 82142c2 | 2014-03-27 14:56:59 +0100 | [diff] [blame] | 2852 | * {@link android.app.trust.TrustManager} for managing trust agents. |
| 2853 | * @see #getSystemService |
| 2854 | * @see android.app.trust.TrustManager |
| 2855 | * @hide |
| 2856 | */ |
| 2857 | public static final String TRUST_SERVICE = "trust"; |
| 2858 | |
| 2859 | /** |
Jae Seo | 3957091 | 2014-02-20 18:23:25 -0800 | [diff] [blame] | 2860 | * Use with {@link #getSystemService} to retrieve a |
Jae Seo | d5cc4a2 | 2014-05-30 16:57:43 -0700 | [diff] [blame] | 2861 | * {@link android.media.tv.TvInputManager} for interacting with TV inputs |
| 2862 | * on the device. |
Jae Seo | 3957091 | 2014-02-20 18:23:25 -0800 | [diff] [blame] | 2863 | * |
| 2864 | * @see #getSystemService |
Jae Seo | d5cc4a2 | 2014-05-30 16:57:43 -0700 | [diff] [blame] | 2865 | * @see android.media.tv.TvInputManager |
Jae Seo | 3957091 | 2014-02-20 18:23:25 -0800 | [diff] [blame] | 2866 | */ |
| 2867 | public static final String TV_INPUT_SERVICE = "tv_input"; |
| 2868 | |
| 2869 | /** |
Jeff Davidson | b51e0a6 | 2014-04-09 12:38:15 -0700 | [diff] [blame] | 2870 | * {@link android.net.NetworkScoreManager} for managing network scoring. |
| 2871 | * @see #getSystemService |
| 2872 | * @see android.net.NetworkScoreManager |
| 2873 | * @hide |
| 2874 | */ |
Jeff Davidson | 5ad2079 | 2014-07-21 13:55:42 -0700 | [diff] [blame] | 2875 | @SystemApi |
Jeff Davidson | b51e0a6 | 2014-04-09 12:38:15 -0700 | [diff] [blame] | 2876 | public static final String NETWORK_SCORE_SERVICE = "network_score"; |
| 2877 | |
| 2878 | /** |
Dianne Hackborn | e22b3b1 | 2014-05-07 18:06:44 -0700 | [diff] [blame] | 2879 | * Use with {@link #getSystemService} to retrieve a {@link |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 2880 | * android.app.usage.UsageStatsManager} for interacting with the status bar. |
Dianne Hackborn | e22b3b1 | 2014-05-07 18:06:44 -0700 | [diff] [blame] | 2881 | * |
| 2882 | * @see #getSystemService |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 2883 | * @see android.app.usage.UsageStatsManager |
Dianne Hackborn | e22b3b1 | 2014-05-07 18:06:44 -0700 | [diff] [blame] | 2884 | * @hide |
| 2885 | */ |
| 2886 | public static final String USAGE_STATS_SERVICE = "usagestats"; |
| 2887 | |
| 2888 | /** |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 2889 | * Use with {@link #getSystemService} to retrieve a {@link |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 2890 | * android.app.job.JobScheduler} instance for managing occasional |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 2891 | * background tasks. |
| 2892 | * @see #getSystemService |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 2893 | * @see android.app.job.JobScheduler |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 2894 | */ |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 2895 | public static final String JOB_SCHEDULER_SERVICE = "jobscheduler"; |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 2896 | |
| 2897 | /** |
Andres Morales | 68d4acd | 2014-07-01 19:40:41 -0700 | [diff] [blame] | 2898 | * Use with {@link #getSystemService} to retrieve a {@link |
Andres Morales | 33df937 | 2014-09-26 17:08:59 -0700 | [diff] [blame] | 2899 | * android.service.persistentdata.PersistentDataBlockManager} instance |
| 2900 | * for interacting with a storage device that lives across factory resets. |
| 2901 | * |
Andres Morales | 68d4acd | 2014-07-01 19:40:41 -0700 | [diff] [blame] | 2902 | * @see #getSystemService |
| 2903 | * @see android.service.persistentdata.PersistentDataBlockManager |
| 2904 | * @hide |
| 2905 | */ |
Andres Morales | 33df937 | 2014-09-26 17:08:59 -0700 | [diff] [blame] | 2906 | @SystemApi |
Andres Morales | 68d4acd | 2014-07-01 19:40:41 -0700 | [diff] [blame] | 2907 | public static final String PERSISTENT_DATA_BLOCK_SERVICE = "persistent_data_block"; |
| 2908 | |
| 2909 | /** |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 2910 | * Use with {@link #getSystemService} to retrieve a {@link |
| 2911 | * android.media.projection.MediaProjectionManager} instance for managing |
| 2912 | * media projection sessions. |
| 2913 | * @see #getSystemService |
| 2914 | * @see android.media.projection.ProjectionManager |
| 2915 | */ |
| 2916 | public static final String MEDIA_PROJECTION_SERVICE = "media_projection"; |
| 2917 | |
| 2918 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2919 | * Determine whether the given permission is allowed for a particular |
| 2920 | * process and user ID running in the system. |
| 2921 | * |
| 2922 | * @param permission The name of the permission being checked. |
| 2923 | * @param pid The process ID being checked against. Must be > 0. |
| 2924 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 2925 | * user, which will pass every permission check. |
| 2926 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 2927 | * @return {@link PackageManager#PERMISSION_GRANTED} if the given |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2928 | * pid/uid is allowed that permission, or |
| 2929 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 2930 | * |
| 2931 | * @see PackageManager#checkPermission(String, String) |
| 2932 | * @see #checkCallingPermission |
| 2933 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2934 | @PackageManager.PermissionResult |
| 2935 | public abstract int checkPermission(@NonNull String permission, int pid, int uid); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2936 | |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 2937 | /** @hide */ |
| 2938 | @PackageManager.PermissionResult |
| 2939 | public abstract int checkPermission(@NonNull String permission, int pid, int uid, |
| 2940 | IBinder callerToken); |
| 2941 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2942 | /** |
| 2943 | * Determine whether the calling process of an IPC you are handling has been |
| 2944 | * granted a particular permission. This is basically the same as calling |
| 2945 | * {@link #checkPermission(String, int, int)} with the pid and uid returned |
| 2946 | * by {@link android.os.Binder#getCallingPid} and |
| 2947 | * {@link android.os.Binder#getCallingUid}. One important difference |
| 2948 | * is that if you are not currently processing an IPC, this function |
| 2949 | * will always fail. This is done to protect against accidentally |
| 2950 | * leaking permissions; you can use {@link #checkCallingOrSelfPermission} |
| 2951 | * to avoid this protection. |
| 2952 | * |
| 2953 | * @param permission The name of the permission being checked. |
| 2954 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 2955 | * @return {@link PackageManager#PERMISSION_GRANTED} if the calling |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2956 | * pid/uid is allowed that permission, or |
| 2957 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 2958 | * |
| 2959 | * @see PackageManager#checkPermission(String, String) |
| 2960 | * @see #checkPermission |
| 2961 | * @see #checkCallingOrSelfPermission |
| 2962 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2963 | @PackageManager.PermissionResult |
| 2964 | public abstract int checkCallingPermission(@NonNull String permission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2965 | |
| 2966 | /** |
| 2967 | * Determine whether the calling process of an IPC <em>or you</em> have been |
| 2968 | * granted a particular permission. This is the same as |
| 2969 | * {@link #checkCallingPermission}, except it grants your own permissions |
| 2970 | * if you are not currently processing an IPC. Use with care! |
| 2971 | * |
| 2972 | * @param permission The name of the permission being checked. |
| 2973 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 2974 | * @return {@link PackageManager#PERMISSION_GRANTED} if the calling |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2975 | * pid/uid is allowed that permission, or |
| 2976 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 2977 | * |
| 2978 | * @see PackageManager#checkPermission(String, String) |
| 2979 | * @see #checkPermission |
| 2980 | * @see #checkCallingPermission |
| 2981 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2982 | @PackageManager.PermissionResult |
| 2983 | public abstract int checkCallingOrSelfPermission(@NonNull String permission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2984 | |
| 2985 | /** |
| 2986 | * If the given permission is not allowed for a particular process |
| 2987 | * and user ID running in the system, throw a {@link SecurityException}. |
| 2988 | * |
| 2989 | * @param permission The name of the permission being checked. |
| 2990 | * @param pid The process ID being checked against. Must be > 0. |
| 2991 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 2992 | * user, which will pass every permission check. |
| 2993 | * @param message A message to include in the exception if it is thrown. |
| 2994 | * |
| 2995 | * @see #checkPermission(String, int, int) |
| 2996 | */ |
| 2997 | public abstract void enforcePermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2998 | @NonNull String permission, int pid, int uid, @Nullable String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2999 | |
| 3000 | /** |
| 3001 | * If the calling process of an IPC you are handling has not been |
| 3002 | * granted a particular permission, throw a {@link |
| 3003 | * SecurityException}. This is basically the same as calling |
| 3004 | * {@link #enforcePermission(String, int, int, String)} with the |
| 3005 | * pid and uid returned by {@link android.os.Binder#getCallingPid} |
| 3006 | * and {@link android.os.Binder#getCallingUid}. One important |
| 3007 | * difference is that if you are not currently processing an IPC, |
| 3008 | * this function will always throw the SecurityException. This is |
| 3009 | * done to protect against accidentally leaking permissions; you |
| 3010 | * can use {@link #enforceCallingOrSelfPermission} to avoid this |
| 3011 | * protection. |
| 3012 | * |
| 3013 | * @param permission The name of the permission being checked. |
| 3014 | * @param message A message to include in the exception if it is thrown. |
| 3015 | * |
| 3016 | * @see #checkCallingPermission(String) |
| 3017 | */ |
| 3018 | public abstract void enforceCallingPermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3019 | @NonNull String permission, @Nullable String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3020 | |
| 3021 | /** |
| 3022 | * If neither you nor the calling process of an IPC you are |
| 3023 | * handling has been granted a particular permission, throw a |
| 3024 | * {@link SecurityException}. This is the same as {@link |
| 3025 | * #enforceCallingPermission}, except it grants your own |
| 3026 | * permissions if you are not currently processing an IPC. Use |
| 3027 | * with care! |
| 3028 | * |
| 3029 | * @param permission The name of the permission being checked. |
| 3030 | * @param message A message to include in the exception if it is thrown. |
| 3031 | * |
| 3032 | * @see #checkCallingOrSelfPermission(String) |
| 3033 | */ |
| 3034 | public abstract void enforceCallingOrSelfPermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3035 | @NonNull String permission, @Nullable String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3036 | |
| 3037 | /** |
| 3038 | * Grant permission to access a specific Uri to another package, regardless |
| 3039 | * of whether that package has general permission to access the Uri's |
| 3040 | * content provider. This can be used to grant specific, temporary |
| 3041 | * permissions, typically in response to user interaction (such as the |
| 3042 | * user opening an attachment that you would like someone else to |
| 3043 | * display). |
| 3044 | * |
| 3045 | * <p>Normally you should use {@link Intent#FLAG_GRANT_READ_URI_PERMISSION |
| 3046 | * Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 3047 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
| 3048 | * Intent.FLAG_GRANT_WRITE_URI_PERMISSION} with the Intent being used to |
| 3049 | * start an activity instead of this function directly. If you use this |
| 3050 | * function directly, you should be sure to call |
| 3051 | * {@link #revokeUriPermission} when the target should no longer be allowed |
| 3052 | * to access it. |
| 3053 | * |
| 3054 | * <p>To succeed, the content provider owning the Uri must have set the |
| 3055 | * {@link android.R.styleable#AndroidManifestProvider_grantUriPermissions |
| 3056 | * grantUriPermissions} attribute in its manifest or included the |
| 3057 | * {@link android.R.styleable#AndroidManifestGrantUriPermission |
| 3058 | * <grant-uri-permissions>} tag. |
| 3059 | * |
| 3060 | * @param toPackage The package you would like to allow to access the Uri. |
| 3061 | * @param uri The Uri you would like to grant access to. |
| 3062 | * @param modeFlags The desired access modes. Any combination of |
| 3063 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3064 | * Intent.FLAG_GRANT_READ_URI_PERMISSION}, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3065 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3066 | * Intent.FLAG_GRANT_WRITE_URI_PERMISSION}, |
| 3067 | * {@link Intent#FLAG_GRANT_PERSISTABLE_URI_PERMISSION |
| 3068 | * Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION}, or |
| 3069 | * {@link Intent#FLAG_GRANT_PREFIX_URI_PERMISSION |
| 3070 | * Intent.FLAG_GRANT_PREFIX_URI_PERMISSION}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3071 | * |
| 3072 | * @see #revokeUriPermission |
| 3073 | */ |
| 3074 | public abstract void grantUriPermission(String toPackage, Uri uri, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3075 | @Intent.GrantUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3076 | |
| 3077 | /** |
| 3078 | * Remove all permissions to access a particular content provider Uri |
| 3079 | * that were previously added with {@link #grantUriPermission}. The given |
| 3080 | * Uri will match all previously granted Uris that are the same or a |
Jeff Sharkey | 328ebf2 | 2013-03-21 18:09:39 -0700 | [diff] [blame] | 3081 | * sub-path of the given Uri. That is, revoking "content://foo/target" will |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3082 | * revoke both "content://foo/target" and "content://foo/target/sub", but not |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3083 | * "content://foo". It will not remove any prefix grants that exist at a |
| 3084 | * higher level. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3085 | * |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 3086 | * <p>Prior to {@link android.os.Build.VERSION_CODES#LOLLIPOP}, if you did not have |
Dianne Hackborn | 192679a | 2014-09-10 14:28:48 -0700 | [diff] [blame] | 3087 | * regular permission access to a Uri, but had received access to it through |
| 3088 | * a specific Uri permission grant, you could not revoke that grant with this |
| 3089 | * function and a {@link SecurityException} would be thrown. As of |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 3090 | * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this function will not throw a security exception, |
Dianne Hackborn | 192679a | 2014-09-10 14:28:48 -0700 | [diff] [blame] | 3091 | * but will remove whatever permission grants to the Uri had been given to the app |
| 3092 | * (or none).</p> |
| 3093 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3094 | * @param uri The Uri you would like to revoke access to. |
| 3095 | * @param modeFlags The desired access modes. Any combination of |
| 3096 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION |
| 3097 | * Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 3098 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
| 3099 | * Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 3100 | * |
| 3101 | * @see #grantUriPermission |
| 3102 | */ |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3103 | public abstract void revokeUriPermission(Uri uri, @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3104 | |
| 3105 | /** |
| 3106 | * Determine whether a particular process and user ID has been granted |
| 3107 | * permission to access a specific URI. This only checks for permissions |
| 3108 | * that have been explicitly granted -- if the given process/uid has |
| 3109 | * more general access to the URI's content provider then this check will |
| 3110 | * always fail. |
| 3111 | * |
| 3112 | * @param uri The uri that is being checked. |
| 3113 | * @param pid The process ID being checked against. Must be > 0. |
| 3114 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 3115 | * user, which will pass every permission check. |
| 3116 | * @param modeFlags The type of access to grant. May be one or both of |
| 3117 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 3118 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 3119 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3120 | * @return {@link PackageManager#PERMISSION_GRANTED} if the given |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3121 | * pid/uid is allowed to access that uri, or |
| 3122 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 3123 | * |
| 3124 | * @see #checkCallingUriPermission |
| 3125 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3126 | public abstract int checkUriPermission(Uri uri, int pid, int uid, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3127 | @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3128 | |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 3129 | /** @hide */ |
| 3130 | public abstract int checkUriPermission(Uri uri, int pid, int uid, |
| 3131 | @Intent.AccessUriMode int modeFlags, IBinder callerToken); |
| 3132 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3133 | /** |
| 3134 | * Determine whether the calling process and user ID has been |
| 3135 | * granted permission to access a specific URI. This is basically |
| 3136 | * the same as calling {@link #checkUriPermission(Uri, int, int, |
| 3137 | * int)} with the pid and uid returned by {@link |
| 3138 | * android.os.Binder#getCallingPid} and {@link |
| 3139 | * android.os.Binder#getCallingUid}. One important difference is |
| 3140 | * that if you are not currently processing an IPC, this function |
| 3141 | * will always fail. |
| 3142 | * |
| 3143 | * @param uri The uri that is being checked. |
| 3144 | * @param modeFlags The type of access to grant. May be one or both of |
| 3145 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 3146 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 3147 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3148 | * @return {@link PackageManager#PERMISSION_GRANTED} if the caller |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3149 | * is allowed to access that uri, or |
| 3150 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 3151 | * |
| 3152 | * @see #checkUriPermission(Uri, int, int, int) |
| 3153 | */ |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3154 | public abstract int checkCallingUriPermission(Uri uri, @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3155 | |
| 3156 | /** |
| 3157 | * Determine whether the calling process of an IPC <em>or you</em> has been granted |
| 3158 | * permission to access a specific URI. This is the same as |
| 3159 | * {@link #checkCallingUriPermission}, except it grants your own permissions |
| 3160 | * if you are not currently processing an IPC. Use with care! |
| 3161 | * |
| 3162 | * @param uri The uri that is being checked. |
| 3163 | * @param modeFlags The type of access to grant. May be one or both of |
| 3164 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 3165 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 3166 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3167 | * @return {@link PackageManager#PERMISSION_GRANTED} if the caller |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3168 | * is allowed to access that uri, or |
| 3169 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 3170 | * |
| 3171 | * @see #checkCallingUriPermission |
| 3172 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3173 | public abstract int checkCallingOrSelfUriPermission(Uri uri, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3174 | @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3175 | |
| 3176 | /** |
| 3177 | * Check both a Uri and normal permission. This allows you to perform |
| 3178 | * both {@link #checkPermission} and {@link #checkUriPermission} in one |
| 3179 | * call. |
| 3180 | * |
| 3181 | * @param uri The Uri whose permission is to be checked, or null to not |
| 3182 | * do this check. |
| 3183 | * @param readPermission The permission that provides overall read access, |
| 3184 | * or null to not do this check. |
| 3185 | * @param writePermission The permission that provides overall write |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3186 | * access, or null to not do this check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3187 | * @param pid The process ID being checked against. Must be > 0. |
| 3188 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 3189 | * user, which will pass every permission check. |
| 3190 | * @param modeFlags The type of access to grant. May be one or both of |
| 3191 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 3192 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 3193 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3194 | * @return {@link PackageManager#PERMISSION_GRANTED} if the caller |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3195 | * is allowed to access that uri or holds one of the given permissions, or |
| 3196 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 3197 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3198 | public abstract int checkUriPermission(@Nullable Uri uri, @Nullable String readPermission, |
| 3199 | @Nullable String writePermission, int pid, int uid, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3200 | @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3201 | |
| 3202 | /** |
| 3203 | * If a particular process and user ID has not been granted |
| 3204 | * permission to access a specific URI, throw {@link |
| 3205 | * SecurityException}. This only checks for permissions that have |
| 3206 | * been explicitly granted -- if the given process/uid has more |
| 3207 | * general access to the URI's content provider then this check |
| 3208 | * will always fail. |
| 3209 | * |
| 3210 | * @param uri The uri that is being checked. |
| 3211 | * @param pid The process ID being checked against. Must be > 0. |
| 3212 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 3213 | * user, which will pass every permission check. |
| 3214 | * @param modeFlags The type of access to grant. May be one or both of |
| 3215 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 3216 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 3217 | * @param message A message to include in the exception if it is thrown. |
| 3218 | * |
| 3219 | * @see #checkUriPermission(Uri, int, int, int) |
| 3220 | */ |
| 3221 | public abstract void enforceUriPermission( |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3222 | Uri uri, int pid, int uid, @Intent.AccessUriMode int modeFlags, String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3223 | |
| 3224 | /** |
| 3225 | * If the calling process and user ID has not been granted |
| 3226 | * permission to access a specific URI, throw {@link |
| 3227 | * SecurityException}. This is basically the same as calling |
| 3228 | * {@link #enforceUriPermission(Uri, int, int, int, String)} with |
| 3229 | * the pid and uid returned by {@link |
| 3230 | * android.os.Binder#getCallingPid} and {@link |
| 3231 | * android.os.Binder#getCallingUid}. One important difference is |
| 3232 | * that if you are not currently processing an IPC, this function |
| 3233 | * will always throw a SecurityException. |
| 3234 | * |
| 3235 | * @param uri The uri that is being checked. |
| 3236 | * @param modeFlags The type of access to grant. May be one or both of |
| 3237 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 3238 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 3239 | * @param message A message to include in the exception if it is thrown. |
| 3240 | * |
| 3241 | * @see #checkCallingUriPermission(Uri, int) |
| 3242 | */ |
| 3243 | public abstract void enforceCallingUriPermission( |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3244 | Uri uri, @Intent.AccessUriMode int modeFlags, String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3245 | |
| 3246 | /** |
| 3247 | * If the calling process of an IPC <em>or you</em> has not been |
| 3248 | * granted permission to access a specific URI, throw {@link |
| 3249 | * SecurityException}. This is the same as {@link |
| 3250 | * #enforceCallingUriPermission}, except it grants your own |
| 3251 | * permissions if you are not currently processing an IPC. Use |
| 3252 | * with care! |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3253 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3254 | * @param uri The uri that is being checked. |
| 3255 | * @param modeFlags The type of access to grant. May be one or both of |
| 3256 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 3257 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 3258 | * @param message A message to include in the exception if it is thrown. |
| 3259 | * |
| 3260 | * @see #checkCallingOrSelfUriPermission(Uri, int) |
| 3261 | */ |
| 3262 | public abstract void enforceCallingOrSelfUriPermission( |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3263 | Uri uri, @Intent.AccessUriMode int modeFlags, String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3264 | |
| 3265 | /** |
| 3266 | * Enforce both a Uri and normal permission. This allows you to perform |
| 3267 | * both {@link #enforcePermission} and {@link #enforceUriPermission} in one |
| 3268 | * call. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3269 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3270 | * @param uri The Uri whose permission is to be checked, or null to not |
| 3271 | * do this check. |
| 3272 | * @param readPermission The permission that provides overall read access, |
| 3273 | * or null to not do this check. |
| 3274 | * @param writePermission The permission that provides overall write |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3275 | * access, or null to not do this check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3276 | * @param pid The process ID being checked against. Must be > 0. |
| 3277 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 3278 | * user, which will pass every permission check. |
| 3279 | * @param modeFlags The type of access to grant. May be one or both of |
| 3280 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 3281 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 3282 | * @param message A message to include in the exception if it is thrown. |
| 3283 | * |
| 3284 | * @see #checkUriPermission(Uri, String, String, int, int, int) |
| 3285 | */ |
| 3286 | public abstract void enforceUriPermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3287 | @Nullable Uri uri, @Nullable String readPermission, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3288 | @Nullable String writePermission, int pid, int uid, @Intent.AccessUriMode int modeFlags, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3289 | @Nullable String message); |
| 3290 | |
| 3291 | /** @hide */ |
| 3292 | @IntDef(flag = true, |
| 3293 | value = {CONTEXT_INCLUDE_CODE, CONTEXT_IGNORE_SECURITY, CONTEXT_RESTRICTED}) |
| 3294 | @Retention(RetentionPolicy.SOURCE) |
| 3295 | public @interface CreatePackageOptions {} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3296 | |
| 3297 | /** |
| 3298 | * Flag for use with {@link #createPackageContext}: include the application |
| 3299 | * code with the context. This means loading code into the caller's |
| 3300 | * process, so that {@link #getClassLoader()} can be used to instantiate |
| 3301 | * the application's classes. Setting this flags imposes security |
| 3302 | * restrictions on what application context you can access; if the |
| 3303 | * requested application can not be safely loaded into your process, |
| 3304 | * java.lang.SecurityException will be thrown. If this flag is not set, |
| 3305 | * there will be no restrictions on the packages that can be loaded, |
| 3306 | * but {@link #getClassLoader} will always return the default system |
| 3307 | * class loader. |
| 3308 | */ |
| 3309 | public static final int CONTEXT_INCLUDE_CODE = 0x00000001; |
| 3310 | |
| 3311 | /** |
| 3312 | * Flag for use with {@link #createPackageContext}: ignore any security |
| 3313 | * restrictions on the Context being requested, allowing it to always |
| 3314 | * be loaded. For use with {@link #CONTEXT_INCLUDE_CODE} to allow code |
| 3315 | * to be loaded into a process even when it isn't safe to do so. Use |
| 3316 | * with extreme care! |
| 3317 | */ |
| 3318 | public static final int CONTEXT_IGNORE_SECURITY = 0x00000002; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3319 | |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 3320 | /** |
| 3321 | * Flag for use with {@link #createPackageContext}: a restricted context may |
| 3322 | * disable specific features. For instance, a View associated with a restricted |
| 3323 | * context would ignore particular XML attributes. |
| 3324 | */ |
| 3325 | public static final int CONTEXT_RESTRICTED = 0x00000004; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3326 | |
| 3327 | /** |
Dianne Hackborn | fee756f | 2014-07-16 17:31:10 -0700 | [diff] [blame] | 3328 | * @hide Used to indicate we should tell the activity manager about the process |
| 3329 | * loading this code. |
| 3330 | */ |
| 3331 | public static final int CONTEXT_REGISTER_PACKAGE = 0x40000000; |
| 3332 | |
| 3333 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3334 | * Return a new Context object for the given application name. This |
| 3335 | * Context is the same as what the named application gets when it is |
| 3336 | * launched, containing the same resources and class loader. Each call to |
| 3337 | * this method returns a new instance of a Context object; Context objects |
| 3338 | * are not shared, however they share common state (Resources, ClassLoader, |
| 3339 | * etc) so the Context instance itself is fairly lightweight. |
| 3340 | * |
| 3341 | * <p>Throws {@link PackageManager.NameNotFoundException} if there is no |
| 3342 | * application with the given package name. |
| 3343 | * |
| 3344 | * <p>Throws {@link java.lang.SecurityException} if the Context requested |
| 3345 | * can not be loaded into the caller's process for security reasons (see |
| 3346 | * {@link #CONTEXT_INCLUDE_CODE} for more information}. |
| 3347 | * |
| 3348 | * @param packageName Name of the application's package. |
| 3349 | * @param flags Option flags, one of {@link #CONTEXT_INCLUDE_CODE} |
| 3350 | * or {@link #CONTEXT_IGNORE_SECURITY}. |
| 3351 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3352 | * @return A {@link Context} for the application. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3353 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3354 | * @throws SecurityException |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3355 | * @throws PackageManager.NameNotFoundException if there is no application with |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3356 | * the given package name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3357 | */ |
| 3358 | public abstract Context createPackageContext(String packageName, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3359 | @CreatePackageOptions int flags) throws PackageManager.NameNotFoundException; |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 3360 | |
| 3361 | /** |
Jeff Sharkey | 6d51571 | 2012-09-20 16:06:08 -0700 | [diff] [blame] | 3362 | * Similar to {@link #createPackageContext(String, int)}, but with a |
| 3363 | * different {@link UserHandle}. For example, {@link #getContentResolver()} |
| 3364 | * will open any {@link Uri} as the given user. |
| 3365 | * |
| 3366 | * @hide |
| 3367 | */ |
| 3368 | public abstract Context createPackageContextAsUser( |
| 3369 | String packageName, int flags, UserHandle user) |
| 3370 | throws PackageManager.NameNotFoundException; |
| 3371 | |
| 3372 | /** |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 3373 | * Creates a context given an {@link android.content.pm.ApplicationInfo}. |
| 3374 | * |
| 3375 | * @hide |
| 3376 | */ |
| 3377 | public abstract Context createApplicationContext(ApplicationInfo application, |
| 3378 | int flags) throws PackageManager.NameNotFoundException; |
| 3379 | |
| 3380 | /** |
Jim Miller | a75a883 | 2013-02-07 16:53:32 -0800 | [diff] [blame] | 3381 | * Get the userId associated with this context |
| 3382 | * @return user id |
| 3383 | * |
| 3384 | * @hide |
| 3385 | */ |
| 3386 | public abstract int getUserId(); |
| 3387 | |
| 3388 | /** |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 3389 | * Return a new Context object for the current Context but whose resources |
| 3390 | * are adjusted to match the given Configuration. Each call to this method |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 3391 | * returns a new instance of a Context object; Context objects are not |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 3392 | * shared, however common state (ClassLoader, other Resources for the |
| 3393 | * same configuration) may be so the Context itself can be fairly lightweight. |
| 3394 | * |
| 3395 | * @param overrideConfiguration A {@link Configuration} specifying what |
| 3396 | * values to modify in the base Configuration of the original Context's |
| 3397 | * resources. If the base configuration changes (such as due to an |
| 3398 | * orientation change), the resources of this context will also change except |
| 3399 | * for those that have been explicitly overridden with a value here. |
| 3400 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3401 | * @return A {@link Context} with the given configuration override. |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 3402 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3403 | public abstract Context createConfigurationContext( |
| 3404 | @NonNull Configuration overrideConfiguration); |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 3405 | |
| 3406 | /** |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 3407 | * Return a new Context object for the current Context but whose resources |
| 3408 | * are adjusted to match the metrics of the given Display. Each call to this method |
| 3409 | * returns a new instance of a Context object; Context objects are not |
| 3410 | * shared, however common state (ClassLoader, other Resources for the |
| 3411 | * same configuration) may be so the Context itself can be fairly lightweight. |
| 3412 | * |
| 3413 | * The returned display Context provides a {@link WindowManager} |
| 3414 | * (see {@link #getSystemService(String)}) that is configured to show windows |
| 3415 | * on the given display. The WindowManager's {@link WindowManager#getDefaultDisplay} |
| 3416 | * method can be used to retrieve the Display from the returned Context. |
| 3417 | * |
| 3418 | * @param display A {@link Display} object specifying the display |
| 3419 | * for whose metrics the Context's resources should be tailored and upon which |
| 3420 | * new windows should be shown. |
| 3421 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3422 | * @return A {@link Context} for the display. |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 3423 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3424 | public abstract Context createDisplayContext(@NonNull Display display); |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 3425 | |
| 3426 | /** |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 3427 | * Gets the display adjustments holder for this context. This information |
| 3428 | * is provided on a per-application or activity basis and is used to simulate lower density |
| 3429 | * display metrics for legacy applications and restricted screen sizes. |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 3430 | * |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 3431 | * @param displayId The display id for which to get compatibility info. |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 3432 | * @return The compatibility info holder, or null if not required by the application. |
| 3433 | * @hide |
| 3434 | */ |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 3435 | public abstract DisplayAdjustments getDisplayAdjustments(int displayId); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 3436 | |
| 3437 | /** |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 3438 | * Indicates whether this Context is restricted. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3439 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3440 | * @return {@code true} if this Context is restricted, {@code false} otherwise. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3441 | * |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 3442 | * @see #CONTEXT_RESTRICTED |
| 3443 | */ |
| 3444 | public boolean isRestricted() { |
| 3445 | return false; |
| 3446 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3447 | } |