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