mobi.voiceassistant.base.content
Class StableContext

java.lang.Object
  extended by android.content.Context
      extended by android.content.ContextWrapper
          extended by mobi.voiceassistant.base.content.StableContext

public final class StableContext
extends ContextWrapper

Special ContextWrapper which is tolerant to device configuration changes

See Also:
Application.onConfigurationChanged(android.content.res.Configuration), Service.onConfigurationChanged(android.content.res.Configuration), Activity.onConfigurationChanged(android.content.res.Configuration), R.attr.configChanges

Field Summary
 
Fields inherited from class android.content.Context
ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, AUDIO_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_WAIVE_PRIORITY, BLUETOOTH_SERVICE, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, DEVICE_POLICY_SERVICE, DISPLAY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, KEYGUARD_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_ROUTER_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, POWER_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, STORAGE_SERVICE, TELEPHONY_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, UI_MODE_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_P2P_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
 
Method Summary
static Context createConfigurationContext(Context base, Configuration overrideConfig)
          Same as createStableContext(android.content.Context) but with overriden configuration.
static Context createDefaultLocaleContext(Context base)
          Same as createStableContext(android.content.Context) but locale is not taken from base but from Locale.getDefault() (which means device's default locale).
static Context createDisplayContext(Context base, Display overrideDisplay)
          Same as createStableContext(android.content.Context) but with overriden configuration.
static Context createLocaleContext(Context base, Locale locale)
          Same as createStableContext(android.content.Context) but with overriden locale.
static Context createStableContext(Context base)
           
 Resources getBaseResources()
           
 Resources getResources()
           
 
Methods inherited from class android.content.ContextWrapper
attachBaseContext, bindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkUriPermission, checkUriPermission, clearWallpaper, createConfigurationContext, createDisplayContext, createPackageContext, databaseList, deleteDatabase, deleteFile, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getContentResolver, getDatabasePath, getDir, getExternalCacheDir, getExternalFilesDir, getFilesDir, getFileStreamPath, getMainLooper, getObbDir, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getSharedPreferences, getSystemService, getTheme, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isRestricted, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setTheme, setWallpaper, setWallpaper, startActivities, startActivities, startActivity, startActivity, startInstrumentation, startIntentSender, startIntentSender, startService, stopService, unbindService, unregisterReceiver
 
Methods inherited from class android.content.Context
getString, getString, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, registerComponentCallbacks, unregisterComponentCallbacks
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getResources

public Resources getResources()
Overrides:
getResources in class ContextWrapper
Returns:
overriden resources
See Also:
Context.getResources()

getBaseResources

public Resources getBaseResources()
Returns:
resources from base context
See Also:
Context.getResources()

createStableContext

public static Context createStableContext(Context base)
Parameters:
base - Base context
Returns:
StableContext backed by base with resources tolerant to configuration changes
Throws:
NullPointerException - if base is null
See Also:
ContextWrapper.ContextWrapper(Context)

createDefaultLocaleContext

public static Context createDefaultLocaleContext(Context base)
Same as createStableContext(android.content.Context) but locale is not taken from base but from Locale.getDefault() (which means device's default locale).

Parameters:
base - Base context
Throws:
NullPointerException - if base is null
See Also:
Locale.getDefault(), createStableContext(android.content.Context), createLocaleContext(android.content.Context, java.util.Locale)

createLocaleContext

public static Context createLocaleContext(Context base,
                                          Locale locale)
Same as createStableContext(android.content.Context) but with overriden locale.

Parameters:
base - Base context
locale - Specific locale or null for locale from base
Throws:
NullPointerException - if base is null
See Also:
createStableContext(android.content.Context)

createConfigurationContext

public static Context createConfigurationContext(Context base,
                                                 Configuration overrideConfig)
Same as createStableContext(android.content.Context) but with overriden configuration.

Parameters:
base - Base context
overrideConfig - Specific configuration or null for configuration from base
Throws:
NullPointerException - if base is null
See Also:
createStableContext(android.content.Context)

createDisplayContext

public static Context createDisplayContext(Context base,
                                           Display overrideDisplay)
Same as createStableContext(android.content.Context) but with overriden configuration.

Parameters:
base - Base context
overrideDisplay - Specific display or null for display from base
Throws:
NullPointerException - if base is null
See Also:
createStableContext(android.content.Context)