List of usage examples for android.content Intent ACTION_CONFIGURATION_CHANGED
String ACTION_CONFIGURATION_CHANGED
To view the source code for android.content Intent ACTION_CONFIGURATION_CHANGED.
Click Source Link
From source file:im.vector.VectorApp.java
@Override public void onCreate() { Log.d(LOG_TAG, "onCreate"); super.onCreate(); if (BuildConfig.DEBUG) { Stetho.initializeWithDefaults(this); }/*ww w.ja va2s . c o m*/ instance = this; mCallsManager = new CallsManager(this); mActivityTransitionTimer = null; mActivityTransitionTimerTask = null; try { PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0); VERSION_BUILD = packageInfo.versionCode; } catch (PackageManager.NameNotFoundException e) { Log.e(LOG_TAG, "fails to retrieve the package info " + e.getMessage()); } VECTOR_VERSION_STRING = Matrix.getInstance(this).getVersion(true, true); // not the first launch if (null != Matrix.getInstance(this).getDefaultSession()) { SDK_VERSION_STRING = Matrix.getInstance(this).getDefaultSession().getVersion(true); } else { SDK_VERSION_STRING = ""; } try { PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); SHORT_VERSION = pInfo.versionName; } catch (Exception e) { } mLogsDirectoryFile = new File(getCacheDir().getAbsolutePath() + "/logs"); org.matrix.androidsdk.util.Log.setLogDirectory(mLogsDirectoryFile); org.matrix.androidsdk.util.Log.init("RiotLog"); // log the application version to trace update // useful to track backward compatibility issues Log.d(LOG_TAG, "----------------------------------------------------------------"); Log.d(LOG_TAG, "----------------------------------------------------------------"); Log.d(LOG_TAG, " Application version: " + VECTOR_VERSION_STRING); Log.d(LOG_TAG, " SDK version: " + SDK_VERSION_STRING); Log.d(LOG_TAG, " Local time: " + (new SimpleDateFormat("MM-dd HH:mm:ss.SSSZ", Locale.US)).format(new Date())); Log.d(LOG_TAG, "----------------------------------------------------------------"); Log.d(LOG_TAG, "----------------------------------------------------------------\n\n\n\n"); mRageShake = new RageShake(this); // init the REST client MXSession.initUserAgent(getApplicationContext()); this.registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() { final Map<String, String> mLocalesByActivity = new HashMap<>(); @Override public void onActivityCreated(Activity activity, Bundle savedInstanceState) { Log.d(LOG_TAG, "onActivityCreated " + activity); mCreatedActivities.add(activity.toString()); ThemeUtils.setActivityTheme(activity); // piwik onNewScreen(activity); } @Override public void onActivityStarted(Activity activity) { Log.d(LOG_TAG, "onActivityStarted " + activity); } /** * Compute the locale status value * @param activity the activity * @return the local status value */ private String getActivityLocaleStatus(Activity activity) { return getApplicationLocale().toString() + "_" + getFontScale() + "_" + ThemeUtils.getApplicationTheme(activity); } @Override public void onActivityResumed(final Activity activity) { Log.d(LOG_TAG, "onActivityResumed " + activity); setCurrentActivity(activity); String activityKey = activity.toString(); if (mLocalesByActivity.containsKey(activityKey)) { String prevActivityLocale = mLocalesByActivity.get(activityKey); if (!TextUtils.equals(prevActivityLocale, getActivityLocaleStatus(activity))) { Log.d(LOG_TAG, "## onActivityResumed() : restart the activity " + activity + " because of the locale update from " + prevActivityLocale + " to " + getActivityLocaleStatus(activity)); restartActivity(activity); return; } } // it should never happen as there is a broadcast receiver (mLanguageReceiver) if (!TextUtils.equals(Locale.getDefault().toString(), getApplicationLocale().toString())) { Log.d(LOG_TAG, "## onActivityResumed() : the locale has been updated to " + Locale.getDefault().toString() + ", restore the expected value " + getApplicationLocale().toString()); updateApplicationSettings(getApplicationLocale(), getFontScale(), ThemeUtils.getApplicationTheme(activity)); restartActivity(activity); } listPermissionStatuses(); } @Override public void onActivityPaused(Activity activity) { Log.d(LOG_TAG, "onActivityPaused " + activity); mLocalesByActivity.put(activity.toString(), getActivityLocaleStatus(activity)); setCurrentActivity(null); onAppPause(); } @Override public void onActivityStopped(Activity activity) { Log.d(LOG_TAG, "onActivityStopped " + activity); } @Override public void onActivitySaveInstanceState(Activity activity, Bundle outState) { Log.d(LOG_TAG, "onActivitySaveInstanceState " + activity); } @Override public void onActivityDestroyed(Activity activity) { Log.d(LOG_TAG, "onActivityDestroyed " + activity); mCreatedActivities.remove(activity.toString()); mLocalesByActivity.remove(activity.toString()); if (mCreatedActivities.size() > 1) { Log.d(LOG_TAG, "onActivityDestroyed : \n" + mCreatedActivities); } } }); // create the markdown parser try { mMarkdownParser = new VectorMarkdownParser(this); } catch (Exception e) { // reported by GA Log.e(LOG_TAG, "cannot create the mMarkdownParser " + e.getMessage()); } // track external language updates // local update from the settings // or screen rotation ! VectorApp.getInstance().registerReceiver(mLanguageReceiver, new IntentFilter(Intent.ACTION_LOCALE_CHANGED)); VectorApp.getInstance().registerReceiver(mLanguageReceiver, new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED)); PreferencesManager.fixMigrationIssues(this); initApplicationLocale(); }
From source file:com.android.mail.browse.ConversationItemView.java
private static synchronized void getItemViewResources(Context context) { if (sConfigurationChangedReceiver == null) { sConfigurationChangedReceiver = new BroadcastReceiver() { @Override//from w ww .j av a2 s . c o m public void onReceive(Context context, Intent intent) { STAR_OFF = null; getItemViewResources(context); } }; context.registerReceiver(sConfigurationChangedReceiver, new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED)); } if (STAR_OFF == null) { final Resources res = context.getResources(); // Initialize static bitmaps. STAR_OFF = BitmapFactory.decodeResource(res, R.drawable.ic_star_outline_20dp); STAR_ON = BitmapFactory.decodeResource(res, R.drawable.ic_star_20dp); ATTACHMENT = BitmapFactory.decodeResource(res, R.drawable.ic_attach_file_18dp); ONLY_TO_ME = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_double); TO_ME_AND_OTHERS = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_single); IMPORTANT_ONLY_TO_ME = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_double_important_unread); IMPORTANT_TO_ME_AND_OTHERS = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_single_important_unread); IMPORTANT = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_none_important_unread); STATE_REPLIED = BitmapFactory.decodeResource(res, R.drawable.ic_badge_reply_holo_light); STATE_FORWARDED = BitmapFactory.decodeResource(res, R.drawable.ic_badge_forward_holo_light); STATE_REPLIED_AND_FORWARDED = BitmapFactory.decodeResource(res, R.drawable.ic_badge_reply_forward_holo_light); STATE_CALENDAR_INVITE = BitmapFactory.decodeResource(res, R.drawable.ic_badge_invite_holo_light); FOCUSED_CONVERSATION_HIGHLIGHT = res.getDrawable(R.drawable.visible_conversation_highlight); // Initialize colors. sActivatedTextSpan = CharacterStyle .wrap(new ForegroundColorSpan(res.getColor(R.color.senders_text_color))); sSendersTextColor = res.getColor(R.color.senders_text_color); sSubjectTextUnreadSpan = new TextAppearanceSpan(context, R.style.SubjectAppearanceUnreadStyle); sSubjectTextReadSpan = new TextAppearanceSpan(context, R.style.SubjectAppearanceReadStyle); sBadgeTextSpan = new TextAppearanceSpan(context, R.style.BadgeTextStyle); sBadgeBackgroundSpan = new BackgroundColorSpan(res.getColor(R.color.badge_background_color)); sDateTextColorRead = res.getColor(R.color.date_text_color_read); sDateTextColorUnread = res.getColor(R.color.date_text_color_unread); sStarTouchSlop = res.getDimensionPixelSize(R.dimen.star_touch_slop); sSenderImageTouchSlop = res.getDimensionPixelSize(R.dimen.sender_image_touch_slop); sShrinkAnimationDuration = res.getInteger(R.integer.shrink_animation_duration); sSlideAnimationDuration = res.getInteger(R.integer.slide_animation_duration); // Initialize static color. sSendersSplitToken = res.getString(R.string.senders_split_token); sElidedPaddingToken = res.getString(R.string.elided_padding_token); sScrollSlop = res.getInteger(R.integer.swipeScrollSlop); sFoldersMaxCount = res.getInteger(R.integer.conversation_list_max_folder_count); sCabAnimationDuration = res.getInteger(R.integer.conv_item_view_cab_anim_duration); sBadgePaddingExtraWidth = res.getDimensionPixelSize(R.dimen.badge_padding_extra_width); sBadgeRoundedCornerRadius = res.getDimensionPixelSize(R.dimen.badge_rounded_corner_radius); sDividerPaint.setColor(res.getColor(R.color.divider_color)); sDividerHeight = res.getDimensionPixelSize(R.dimen.divider_height); } }
From source file:com.android.leanlauncher.LauncherModel.java
/** * Call from the handler for ACTION_PACKAGE_ADDED, ACTION_PACKAGE_REMOVED and * ACTION_PACKAGE_CHANGED./*from www.j a va2 s. c om*/ */ @Override public void onReceive(Context context, Intent intent) { if (DEBUG_RECEIVER) Log.d(TAG, "onReceive intent=" + intent); final String action = intent.getAction(); if (Intent.ACTION_LOCALE_CHANGED.equals(action)) { // If we have changed locale we need to clear out the labels in all apps/workspace. forceReload(); } else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) { // Check if configuration change was an mcc/mnc change which would affect app resources // and we would need to clear out the labels in all apps/workspace. Same handling as // above for ACTION_LOCALE_CHANGED Configuration currentConfig = context.getResources().getConfiguration(); if (mPreviousConfigMcc != currentConfig.mcc) { Log.d(TAG, "Reload apps on config change. curr_mcc:" + currentConfig.mcc + " prevmcc:" + mPreviousConfigMcc); forceReload(); } // Update previousConfig mPreviousConfigMcc = currentConfig.mcc; } }
From source file:saphion.services.ForegroundService.java
@SuppressWarnings("deprecation") @Override/*from w w w.ja v a 2s.c o m*/ public void onCreate() { mPref = ForegroundService.this.getSharedPreferences(PREF_NAME, MODE_MULTI_PROCESS); // receive ACTION_BATTERY_CHANGED. IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_BATTERY_CHANGED); filter.addAction(Intent.ACTION_POWER_CONNECTED); filter.addAction(Intent.ACTION_POWER_DISCONNECTED); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_SCREEN_ON); filter.addAction(Intents.MYBAT_INTENT); filter.addAction(Intents.TORCH_ON); filter.addAction(Intents.TORCH_OFF); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED); filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); filter.addAction(ConnectivityManager.ACTION_BACKGROUND_DATA_SETTING_CHANGED); filter.addAction(Intents.SWITCHER_INTENT); filter.addAction(Intents.SWITCHER_NOTI); filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); } registerReceiver(mBroadcastReceiver, filter); readbattery(); mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); if (!mPref.getBoolean(PreferenceHelper.NOTIFICATION_ENABLE, true)) { mNM.cancelAll();// .notify(id, notification); } try { mStartForeground = getClass().getMethod("startForeground", mStartForegroundSignature); mStopForeground = getClass().getMethod("stopForeground", mStopForegroundSignature); return; } catch (NoSuchMethodException e) { // Running on an older platform. mStartForeground = mStopForeground = null; } try { mSetForeground = getClass().getMethod("setForeground", mSetForegroundSignature); } catch (NoSuchMethodException e) { throw new IllegalStateException("OS doesn't have Service.startForeground OR Service.setForeground!"); } }
From source file:com.tct.mail.browse.ConversationItemView.java
private static synchronized void getItemViewResources(Context context) { if (sConfigurationChangedReceiver == null) { sConfigurationChangedReceiver = new BroadcastReceiver() { @Override// w ww . j a va 2s . com public void onReceive(Context context, Intent intent) { STAR_OFF = null; //[BUGFIX]-Mod-BEGIN by TCTNB.caixia.chen,01/07/2015,PR 893304 getItemViewResources(context.getApplicationContext()); //[BUGFIX]-Mod-END by TCTNB.caixia.chen } }; context.registerReceiver(sConfigurationChangedReceiver, new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED)); } if (STAR_OFF == null) { final Resources res = context.getResources(); // Initialize static bitmaps. //TS: junwei-xu 2015-09-02 EMAIL BUGFIX-546917 MOD-S // star off will not show in list item. //STAR_OFF = BitmapFactory.decodeResource(res, R.drawable.ic_star_outline_20dp); STAR_OFF = BitmapFactory.decodeResource(res, R.drawable.ic_importance_normal); //TS: junwei-xu 2015-09-02 EMAIL BUGFIX-546917 MOD-S STAR_ON = BitmapFactory.decodeResource(res, R.drawable.ic_star_20dp); ATTACHMENT = BitmapFactory.decodeResource(res, R.drawable.ic_attach_file_20dp); ONLY_TO_ME = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_double); TO_ME_AND_OTHERS = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_single); IMPORTANT_ONLY_TO_ME = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_double_important_unread); IMPORTANT_TO_ME_AND_OTHERS = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_single_important_unread); IMPORTANT = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_none_important_unread); STATE_REPLIED = BitmapFactory.decodeResource(res, R.drawable.ic_badge_reply_holo_light); STATE_FORWARDED = BitmapFactory.decodeResource(res, R.drawable.ic_badge_forward_holo_light); STATE_REPLIED_AND_FORWARDED = BitmapFactory.decodeResource(res, R.drawable.ic_badge_reply_forward_holo_light); STATE_CALENDAR_INVITE = BitmapFactory.decodeResource(res, R.drawable.ic_badge_invite_holo_light); VISIBLE_CONVERSATION_HIGHLIGHT = res.getDrawable(R.drawable.visible_conversation_highlight); RIGHT_EDGE_TABLET = res.getDrawable(R.drawable.list_edge_tablet); //[FEATURE]-Add-BEGIN by TSCD.chao zhang,04/17/2014,FR 631895(porting from FR514398) sHighPriorityIcon = BitmapFactory.decodeResource(res, R.drawable.ic_high_priority); sLowPriorityIcon = BitmapFactory.decodeResource(res, R.drawable.ic_low_priority); sNormalPriorityIcon = BitmapFactory.decodeResource(res, R.drawable.ic_importance_normal); //[FEATURE]-Add-END by TSCD.chao zhang // Initialize colors. sActivatedTextSpan = CharacterStyle .wrap(new ForegroundColorSpan(res.getColor(R.color.senders_text_color))); sSendersTextColor = res.getColor(R.color.senders_text_color); sSubjectTextUnreadSpan = new TextAppearanceSpan(context, R.style.SubjectAppearanceUnreadStyle); sSubjectTextReadSpan = new TextAppearanceSpan(context, R.style.SubjectAppearanceReadStyle); sBadgeTextSpan = new TextAppearanceSpan(context, R.style.BadgeTextStyle); sBadgeBackgroundSpan = new BackgroundColorSpan(res.getColor(R.color.badge_background_color)); sDateTextColorRead = res.getColor(R.color.date_text_color_read); sDateTextColorUnread = res.getColor(R.color.date_text_color_unread); sStarTouchSlop = res.getDimensionPixelSize(R.dimen.star_touch_slop); sSenderImageTouchSlop = res.getDimensionPixelSize(R.dimen.sender_image_touch_slop); sShrinkAnimationDuration = res.getInteger(R.integer.shrink_animation_duration); sSlideAnimationDuration = res.getInteger(R.integer.slide_animation_duration); // Initialize static color. sSendersSplitToken = res.getString(R.string.senders_split_token); sElidedPaddingToken = res.getString(R.string.elided_padding_token); sScrollSlop = res.getInteger(R.integer.swipeScrollSlop); sFoldersStartPadding = res.getDimensionPixelOffset(R.dimen.folders_start_padding); sFoldersInnerPadding = res.getDimensionPixelOffset(R.dimen.folder_cell_content_padding); sFoldersMaxCount = res.getInteger(R.integer.conversation_list_max_folder_count); sFoldersOverflowGradientPadding = res.getDimensionPixelOffset(R.dimen.folders_gradient_padding); sCabAnimationDuration = res.getInteger(R.integer.conv_item_view_cab_anim_duration); sBadgePaddingExtraWidth = res.getDimensionPixelSize(R.dimen.badge_padding_extra_width); sBadgeRoundedCornerRadius = res.getDimensionPixelSize(R.dimen.badge_rounded_corner_radius); sFolderRoundedCornerRadius = res.getDimensionPixelOffset(R.dimen.folder_rounded_corner_radius); sDividerColor = res.getColor(R.color.conversation_list_divider_color); sDividerInset = res.getDimensionPixelSize(R.dimen.conv_list_divider_inset); sDividerHeight = res.getDimensionPixelSize(R.dimen.divider_height); } }