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