Java Code Examples for android.content.Intent#ACTION_LOCALE_CHANGED
The following examples show how to use
android.content.Intent#ACTION_LOCALE_CHANGED .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MoreWidgetProvider.java From good-weather with GNU General Public License v3.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { switch (intent.getAction()) { case Constants.ACTION_FORCED_APPWIDGET_UPDATE: if(AppPreference.isUpdateLocationEnabled(context)) { context.startService(new Intent(context, LocationUpdateService.class)); } else { context.startService(new Intent(context, MoreWidgetService.class)); } break; case Intent.ACTION_LOCALE_CHANGED: context.startService(new Intent(context, MoreWidgetService.class)); break; case Constants.ACTION_APPWIDGET_THEME_CHANGED: AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); ComponentName componentName = new ComponentName(context, MoreWidgetProvider.class); int[] appWidgetIds = appWidgetManager.getAppWidgetIds(componentName); onUpdate(context, appWidgetManager, appWidgetIds); break; case Constants.ACTION_APPWIDGET_UPDATE_PERIOD_CHANGED: AppWidgetProviderAlarm widgetProviderAlarm = new AppWidgetProviderAlarm(context, MoreWidgetProvider.class); if (widgetProviderAlarm.isAlarmOff()) { break; } else { widgetProviderAlarm.setAlarm(); } break; default: super.onReceive(context, intent); } }
Example 2
Source File: LessWidgetProvider.java From good-weather with GNU General Public License v3.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { switch (intent.getAction()) { case Constants.ACTION_FORCED_APPWIDGET_UPDATE: if(AppPreference.isUpdateLocationEnabled(context)) { context.startService(new Intent(context, LocationUpdateService.class)); } else { context.startService(new Intent(context, LessWidgetService.class)); } break; case Intent.ACTION_LOCALE_CHANGED: context.startService(new Intent(context, LessWidgetService.class)); break; case Constants.ACTION_APPWIDGET_THEME_CHANGED: AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); ComponentName componentName = new ComponentName(context, LessWidgetProvider.class); int[] appWidgetIds = appWidgetManager.getAppWidgetIds(componentName); onUpdate(context, appWidgetManager, appWidgetIds); break; case Constants.ACTION_APPWIDGET_UPDATE_PERIOD_CHANGED: AppWidgetProviderAlarm widgetProviderAlarm = new AppWidgetProviderAlarm(context, LessWidgetProvider.class); if (widgetProviderAlarm.isAlarmOff()) { break; } else { widgetProviderAlarm.setAlarm(); } break; default: super.onReceive(context, intent); } }
Example 3
Source File: LollipopBrowserAccessibilityManager.java From 365browser with Apache License 2.0 | 5 votes |
LollipopBrowserAccessibilityManager(long nativeBrowserAccessibilityManagerAndroid, ContentViewCore contentViewCore) { super(nativeBrowserAccessibilityManagerAndroid, contentViewCore); // Cache the system language and set up a listener for when it changes. IntentFilter filter = new IntentFilter(Intent.ACTION_LOCALE_CHANGED); mContentViewCore.getContext().registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { mSystemLanguageTag = Locale.getDefault().toLanguageTag(); } }, filter); mSystemLanguageTag = Locale.getDefault().toLanguageTag(); }
Example 4
Source File: AbstractWidgetProvider.java From your-local-weather with GNU General Public License v3.0 | 4 votes |
private void performActionOnReceiveForWidget(Context context, Intent intent, int widgetId) { AppWidgetManager widgetManager = AppWidgetManager.getInstance(context); LocationsDbHelper locationsDbHelper = LocationsDbHelper.getInstance(context); WidgetSettingsDbHelper widgetSettingsDbHelper = WidgetSettingsDbHelper.getInstance(context); Long locationId = widgetSettingsDbHelper.getParamLong(widgetId, "locationId"); if (locationId == null) { currentLocation = locationsDbHelper.getLocationByOrderId(0); if (!currentLocation.isEnabled()) { currentLocation = locationsDbHelper.getLocationByOrderId(1); } } else { currentLocation = locationsDbHelper.getLocationById(locationId); } switch (intent.getAction()) { case "org.thosp.yourlocalweather.action.WEATHER_UPDATE_RESULT": case "android.appwidget.action.APPWIDGET_UPDATE": if (!servicesStarted) { onEnabled(context); servicesStarted = true; } onUpdate(context, widgetManager, new int[] {widgetId}); break; case Intent.ACTION_LOCALE_CHANGED: case Constants.ACTION_APPWIDGET_THEME_CHANGED: case Constants.ACTION_APPWIDGET_SETTINGS_SHOW_CONTROLS: refreshWidgetValues(context); break; case Constants.ACTION_APPWIDGET_UPDATE_PERIOD_CHANGED: onEnabled(context); break; case Constants.ACTION_APPWIDGET_CHANGE_SETTINGS: onUpdate(context, widgetManager, new int[]{ widgetId}); break; } if (intent.getAction().startsWith(Constants.ACTION_APPWIDGET_SETTINGS_OPENED)) { String[] params = intent.getAction().split("__"); String widgetIdTxt = params[1]; widgetId = Integer.parseInt(widgetIdTxt); openWidgetSettings(context, widgetId, params[2]); } else if (intent.getAction().startsWith(Constants.ACTION_APPWIDGET_START_ACTIVITY)) { AppPreference.setCurrentLocationId(context, currentLocation); Long widgetActionId = intent.getLongExtra("widgetAction", 1); Class activityClass = WidgetActions.getById(widgetActionId, "action_current_weather_icon").getActivityClass(); Intent activityIntent = new Intent(context, activityClass); activityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); context.startActivity(activityIntent); } else if (intent.getAction().startsWith(Constants.ACTION_APPWIDGET_CHANGE_LOCATION)) { changeLocation(widgetId, locationsDbHelper, widgetSettingsDbHelper); GraphUtils.invalidateGraph(); onUpdate(context, widgetManager, new int[]{widgetId}); } else if (intent.getAction().startsWith(Constants.ACTION_FORCED_APPWIDGET_UPDATE)) { if (!WidgetRefreshIconService.isRotationActive) { sendWeatherUpdate(context, widgetId); } onUpdate(context, widgetManager, new int[]{ widgetId}); } }
Example 5
Source File: AlarmsService.java From OmniList with GNU Affero General Public License v3.0 | 4 votes |
@Override public int onStartCommand(Intent intent, int flags, int startId) { String action = intent.getAction(); if (action == null) { throw new IllegalArgumentException("Illegal action"); } switch (action){ case Intent.ACTION_BOOT_COMPLETED: LogUtils.d("onStartCommand: " + "android.intent.action.BOOT_COMPLETED"); alarmsManager.registerAllAlarms(); break; case Intent.ACTION_TIMEZONE_CHANGED: LogUtils.d("onStartCommand: " + "android.intent.action.TIMEZONE_CHANGED"); alarmsManager.registerAllAlarms(); break; case Intent.ACTION_LOCALE_CHANGED: LogUtils.d("onStartCommand: " + "android.intent.action.LOCALE_CHANGED"); alarmsManager.registerAllAlarms(); break; case Intent.ACTION_TIME_CHANGED: LogUtils.d("onStartCommand: " + "android.intent.action.TIME_SET"); alarmsManager.registerAllAlarms(); break; } int code = -1; try { code = intent.getIntExtra(Constants.EXTRA_CODE, -1); switch (action) { case PresentationToModelIntents.ACTION_REQUEST_SNOOZE: alarmsManager.snooze(code, null); break; case PresentationToModelIntents.ACTION_REQUEST_DISMISS: alarmsManager.dismiss(code); break; } } catch (AlarmNotFoundException e) { LogUtils.d("onStartCommand: Alarm not found [ code:" + code + "]"); } return START_NOT_STICKY; }
Example 6
Source File: ApplicationContext.java From deltachat-android with GNU General Public License v3.0 | 4 votes |
@Override public void onCreate() { super.onCreate(); // if (LeakCanary.isInAnalyzerProcess(this)) { // // This process is dedicated to LeakCanary for heap analysis. // // You should not init your app in this process. // return; // } // LeakCanary.install(this); Log.i("DeltaChat", "++++++++++++++++++ ApplicationContext.onCreate() ++++++++++++++++++"); System.loadLibrary("native-utils"); dcContext = new ApplicationDcContext(this); new ForegroundDetector(ApplicationContext.getInstance(this)); BroadcastReceiver networkStateReceiver = new NetworkStateReceiver(); registerReceiver(networkStateReceiver, new IntentFilter(android.net.ConnectivityManager.CONNECTIVITY_ACTION)); KeepAliveService.maybeStartSelf(this); initializeRandomNumberFix(); initializeLogging(); initializeJobManager(); ProcessLifecycleOwner.get().getLifecycle().addObserver(this); InChatSounds.getInstance(this); dcLocationManager = new DcLocationManager(this); try { DynamicLanguage.setContextLocale(this, DynamicLanguage.getSelectedLocale(this)); } catch (Exception e) { e.printStackTrace(); } dcContext.setStockTranslations(); IntentFilter filter = new IntentFilter(Intent.ACTION_LOCALE_CHANGED); registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { dcContext.setStockTranslations(); } }, filter); // MAYBE TODO: i think the ApplicationContext is also created // when the app is stated by FetchWorker timeouts. // in this case, the normal threads shall not be started. Constraints constraints = new Constraints.Builder() .setRequiredNetworkType(NetworkType.CONNECTED) .build(); PeriodicWorkRequest fetchWorkRequest = new PeriodicWorkRequest.Builder( FetchWorker.class, PeriodicWorkRequest.MIN_PERIODIC_INTERVAL_MILLIS, // usually 15 minutes TimeUnit.MILLISECONDS, PeriodicWorkRequest.MIN_PERIODIC_FLEX_MILLIS, // the start may be preferred by up to 5 minutes, so we run every 10-15 minutes TimeUnit.MILLISECONDS) .setConstraints(constraints) .build(); WorkManager.getInstance(this).enqueueUniquePeriodicWork( "FetchWorker", ExistingPeriodicWorkPolicy.KEEP, fetchWorkRequest); }