List of usage examples for android.media AudioManager RINGER_MODE_CHANGED_ACTION
String RINGER_MODE_CHANGED_ACTION
To view the source code for android.media AudioManager RINGER_MODE_CHANGED_ACTION.
Click Source Link
From source file:com.ayaseya.padnotification.GcmIntentService.java
@Override public void onCreate() { super.onCreate(); ringerMode = false;/*from ww w . j a v a 2 s . c o m*/ silentMode = false; vibrateMode = false; isPlugged = false; sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); checkbox_sound = sharedPreferences.getBoolean("checkbox_sound_key", true); checkbox_vibration = sharedPreferences.getBoolean("checkbox_vibration_key", false); Set<String> multiValues = sharedPreferences.getStringSet("list_preference", null); ArrayList<String> timeZone = new ArrayList<String>(); if (multiValues != null) { timeZone.addAll(multiValues); Collections.sort(timeZone); for (int i = 0; i < timeZone.size(); i++) { // Log.v(TAG, "TimeZone=" + timeZone.get(i)); } Calendar calendar = Calendar.getInstance(); int hour = calendar.get(Calendar.HOUR_OF_DAY); if (timeZone.indexOf(String.valueOf(hour)) == -1) { notificationPermission = false; Log.v(TAG, "?????????"); } else { notificationPermission = true; Log.v(TAG, "??????"); } } vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE); ringerModeStateChangeReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // ? if (intent.getAction().equals(AudioManager.RINGER_MODE_CHANGED_ACTION)) { if (intent.getIntExtra(AudioManager.EXTRA_RINGER_MODE, -1) == AudioManager.RINGER_MODE_NORMAL) { // ringerMode = true; } else { ringerMode = false; } if (intent.getIntExtra(AudioManager.EXTRA_RINGER_MODE, -1) == AudioManager.RINGER_MODE_VIBRATE) { // vibrateMode = true; } else { vibrateMode = false; } if (intent.getIntExtra(AudioManager.EXTRA_RINGER_MODE, -1) == AudioManager.RINGER_MODE_SILENT) { // silentMode = true; } else { silentMode = false; } } } }; plugStateChangeReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // ? if (intent.getIntExtra("state", 0) > 0) { isPlugged = true; // Log.v(TAG, "IN"); } else { isPlugged = false; // Log.v(TAG, "OUT"); } } }; // Broadcast Receiver??? registerReceiver(plugStateChangeReceiver, plugIntentFilter); registerReceiver(ringerModeStateChangeReceiver, ringerModeIntentFilter); }
From source file:com.ayaseya.nolnotification.GcmIntentService.java
@Override public void onCreate() { super.onCreate(); ringerMode = false;/*from www . j a v a 2s . c om*/ silentMode = false; vibrateMode = false; isPlugged = false; sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); checkbox_sound = sharedPreferences.getBoolean("checkbox_sound_key", true); checkbox_vibration = sharedPreferences.getBoolean("checkbox_vibration_key", false); Set<String> multiValues = sharedPreferences.getStringSet("list_preference", null); ArrayList<String> timeZone = new ArrayList<String>(); if (multiValues != null) { timeZone.addAll(multiValues); Collections.sort(timeZone); for (int i = 0; i < timeZone.size(); i++) { // Log.v(TAG, "TimeZone=" + timeZone.get(i)); } Calendar calendar = Calendar.getInstance(); int hour = calendar.get(Calendar.HOUR_OF_DAY); if (timeZone.indexOf(String.valueOf(hour)) == -1) { notificationPermission = false; // Log.v(TAG, "?????????"); } else { notificationPermission = true; // Log.v(TAG, "??????"); } } vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE); ringerModeStateChangeReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // ? if (intent.getAction().equals(AudioManager.RINGER_MODE_CHANGED_ACTION)) { if (intent.getIntExtra(AudioManager.EXTRA_RINGER_MODE, -1) == AudioManager.RINGER_MODE_NORMAL) { // ringerMode = true; } else { ringerMode = false; } if (intent.getIntExtra(AudioManager.EXTRA_RINGER_MODE, -1) == AudioManager.RINGER_MODE_VIBRATE) { // vibrateMode = true; } else { vibrateMode = false; } if (intent.getIntExtra(AudioManager.EXTRA_RINGER_MODE, -1) == AudioManager.RINGER_MODE_SILENT) { // silentMode = true; } else { silentMode = false; } } } }; plugStateChangeReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // ? if (intent.getIntExtra("state", 0) > 0) { isPlugged = true; // Log.v(TAG, "IN"); } else { isPlugged = false; // Log.v(TAG, "OUT"); } } }; // Broadcast Receiver??? registerReceiver(plugStateChangeReceiver, plugIntentFilter); registerReceiver(ringerModeStateChangeReceiver, ringerModeIntentFilter); }
From source file:org.pocketworkstation.pckeyboard.LatinIME.java
@Override public void onCreate() { Log.i("PCKeyboard", "onCreate(), os.version=" + System.getProperty("os.version")); KeyboardSwitcher.init(this); super.onCreate(); sInstance = this; // setStatusIcon(R.drawable.ime_qwerty); mResources = getResources();//from w w w . jav a 2 s . c o m final Configuration conf = mResources.getConfiguration(); mOrientation = conf.orientation; final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); mLanguageSwitcher = new LanguageSwitcher(this); mLanguageSwitcher.loadLocales(prefs); mKeyboardSwitcher = KeyboardSwitcher.getInstance(); mKeyboardSwitcher.setLanguageSwitcher(mLanguageSwitcher); mSystemLocale = conf.locale.toString(); mLanguageSwitcher.setSystemLocale(conf.locale); String inputLanguage = mLanguageSwitcher.getInputLanguage(); if (inputLanguage == null) { inputLanguage = conf.locale.toString(); } Resources res = getResources(); mReCorrectionEnabled = prefs.getBoolean(PREF_RECORRECTION_ENABLED, res.getBoolean(R.bool.default_recorrection_enabled)); mConnectbotTabHack = prefs.getBoolean(PREF_CONNECTBOT_TAB_HACK, res.getBoolean(R.bool.default_connectbot_tab_hack)); mFullscreenOverride = prefs.getBoolean(PREF_FULLSCREEN_OVERRIDE, res.getBoolean(R.bool.default_fullscreen_override)); mForceKeyboardOn = prefs.getBoolean(PREF_FORCE_KEYBOARD_ON, res.getBoolean(R.bool.default_force_keyboard_on)); mKeyboardNotification = prefs.getBoolean(PREF_KEYBOARD_NOTIFICATION, res.getBoolean(R.bool.default_keyboard_notification)); mSuggestionsInLandscape = prefs.getBoolean(PREF_SUGGESTIONS_IN_LANDSCAPE, res.getBoolean(R.bool.default_suggestions_in_landscape)); mHeightPortrait = getHeight(prefs, PREF_HEIGHT_PORTRAIT, res.getString(R.string.default_height_portrait)); mHeightLandscape = getHeight(prefs, PREF_HEIGHT_LANDSCAPE, res.getString(R.string.default_height_landscape)); LatinIME.sKeyboardSettings.hintMode = Integer .parseInt(prefs.getString(PREF_HINT_MODE, res.getString(R.string.default_hint_mode))); LatinIME.sKeyboardSettings.longpressTimeout = getPrefInt(prefs, PREF_LONGPRESS_TIMEOUT, res.getString(R.string.default_long_press_duration)); LatinIME.sKeyboardSettings.renderMode = getPrefInt(prefs, PREF_RENDER_MODE, res.getString(R.string.default_render_mode)); mSwipeUpAction = prefs.getString(PREF_SWIPE_UP, res.getString(R.string.default_swipe_up)); mSwipeDownAction = prefs.getString(PREF_SWIPE_DOWN, res.getString(R.string.default_swipe_down)); mSwipeLeftAction = prefs.getString(PREF_SWIPE_LEFT, res.getString(R.string.default_swipe_left)); mSwipeRightAction = prefs.getString(PREF_SWIPE_RIGHT, res.getString(R.string.default_swipe_right)); mVolUpAction = prefs.getString(PREF_VOL_UP, res.getString(R.string.default_vol_up)); mVolDownAction = prefs.getString(PREF_VOL_DOWN, res.getString(R.string.default_vol_down)); sKeyboardSettings.initPrefs(prefs, res); mVoiceRecognitionTrigger = new VoiceRecognitionTrigger(this); updateKeyboardOptions(); PluginManager.getPluginDictionaries(getApplicationContext()); mPluginManager = new PluginManager(this); final IntentFilter pFilter = new IntentFilter(); pFilter.addDataScheme("package"); pFilter.addAction("android.intent.action.PACKAGE_ADDED"); pFilter.addAction("android.intent.action.PACKAGE_REPLACED"); pFilter.addAction("android.intent.action.PACKAGE_REMOVED"); registerReceiver(mPluginManager, pFilter); LatinIMEUtil.GCUtils.getInstance().reset(); boolean tryGC = true; for (int i = 0; i < LatinIMEUtil.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) { try { initSuggest(inputLanguage); tryGC = false; } catch (OutOfMemoryError e) { tryGC = LatinIMEUtil.GCUtils.getInstance().tryGCOrWait(inputLanguage, e); } } mOrientation = conf.orientation; // register to receive ringer mode changes for silent mode IntentFilter filter = new IntentFilter(AudioManager.RINGER_MODE_CHANGED_ACTION); registerReceiver(mReceiver, filter); prefs.registerOnSharedPreferenceChangeListener(this); setNotification(mKeyboardNotification); }
From source file:org.distantshoresmedia.keyboard.LatinIME.java
@Override public void onCreate() { Log.i("PCKeyboard", "onCreate(), os.version=" + System.getProperty("os.version")); TKIMELogger.init(this); KeyboardSwitcher.init(this); super.onCreate(); sInstance = this; // setStatusIcon(R.drawable.ime_qwerty); mResources = getResources();/*from ww w .j a va 2 s . c o m*/ final Configuration conf = mResources.getConfiguration(); mOrientation = conf.orientation; final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); mLanguageSwitcher = new LanguageSwitcher(this); mLanguageSwitcher.loadLocales(prefs); mKeyboardSwitcher = KeyboardSwitcher.getInstance(); mKeyboardSwitcher.setLanguageSwitcher(mLanguageSwitcher); mSystemLocale = conf.locale.toString(); mLanguageSwitcher.setSystemLocale(conf.locale); String inputLanguage = mLanguageSwitcher.getInputLanguage(); if (inputLanguage == null) { inputLanguage = conf.locale.toString(); } Resources res = getResources(); mReCorrectionEnabled = prefs.getBoolean(PREF_RECORRECTION_ENABLED, res.getBoolean(R.bool.default_recorrection_enabled)); mConnectbotTabHack = prefs.getBoolean(PREF_CONNECTBOT_TAB_HACK, res.getBoolean(R.bool.default_connectbot_tab_hack)); mFullscreenOverride = prefs.getBoolean(PREF_FULLSCREEN_OVERRIDE, res.getBoolean(R.bool.default_fullscreen_override)); mForceKeyboardOn = prefs.getBoolean(PREF_FORCE_KEYBOARD_ON, res.getBoolean(R.bool.default_force_keyboard_on)); mKeyboardNotification = prefs.getBoolean(PREF_KEYBOARD_NOTIFICATION, res.getBoolean(R.bool.default_keyboard_notification)); mSuggestionsInLandscape = prefs.getBoolean(PREF_SUGGESTIONS_IN_LANDSCAPE, res.getBoolean(R.bool.default_suggestions_in_landscape)); mHeightPortrait = getHeight(prefs, PREF_HEIGHT_PORTRAIT, res.getString(R.string.default_height_portrait)); mHeightLandscape = getHeight(prefs, PREF_HEIGHT_LANDSCAPE, res.getString(R.string.default_height_landscape)); LatinIME.sKeyboardSettings.hintMode = Integer .parseInt(prefs.getString(PREF_HINT_MODE, res.getString(R.string.default_hint_mode))); LatinIME.sKeyboardSettings.longpressTimeout = getPrefInt(prefs, PREF_LONGPRESS_TIMEOUT, res.getString(R.string.default_long_press_duration)); LatinIME.sKeyboardSettings.renderMode = getPrefInt(prefs, PREF_RENDER_MODE, res.getString(R.string.default_render_mode)); mSwipeUpAction = prefs.getString(PREF_SWIPE_UP, res.getString(R.string.default_swipe_up)); mSwipeDownAction = prefs.getString(PREF_SWIPE_DOWN, res.getString(R.string.default_swipe_down)); mSwipeLeftAction = prefs.getString(PREF_SWIPE_LEFT, res.getString(R.string.default_swipe_left)); mSwipeRightAction = prefs.getString(PREF_SWIPE_RIGHT, res.getString(R.string.default_swipe_right)); mVolUpAction = prefs.getString(PREF_VOL_UP, res.getString(R.string.default_vol_up)); mVolDownAction = prefs.getString(PREF_VOL_DOWN, res.getString(R.string.default_vol_down)); sKeyboardSettings.initPrefs(prefs, res); // mVoiceRecognitionTrigger = new VoiceRecognitionTrigger(this); updateKeyboardOptions(); PluginManager.getPluginDictionaries(getApplicationContext()); mPluginManager = new PluginManager(this); final IntentFilter pFilter = new IntentFilter(); pFilter.addDataScheme("package"); pFilter.addAction("android.intent.action.PACKAGE_ADDED"); pFilter.addAction("android.intent.action.PACKAGE_REPLACED"); pFilter.addAction("android.intent.action.PACKAGE_REMOVED"); registerReceiver(mPluginManager, pFilter); TKIMEUtil.GCUtils.getInstance().reset(); boolean tryGC = true; for (int i = 0; i < TKIMEUtil.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) { try { initSuggest(inputLanguage); tryGC = false; } catch (OutOfMemoryError e) { tryGC = TKIMEUtil.GCUtils.getInstance().tryGCOrWait(inputLanguage, e); } } mOrientation = conf.orientation; // register to receive ringer mode changes for silent mode IntentFilter filter = new IntentFilter(AudioManager.RINGER_MODE_CHANGED_ACTION); registerReceiver(mReceiver, filter); prefs.registerOnSharedPreferenceChangeListener(this); setNotification(mKeyboardNotification); }
From source file:com.mobiletin.inputmethod.indic.LatinIME.java
@Override public void onCreate() { Settings.init(this); DebugFlags.init(PreferenceManager.getDefaultSharedPreferences(this)); RichInputMethodManager.init(this); mRichImm = RichInputMethodManager.getInstance(); SubtypeSwitcher.init(this); KeyboardSwitcher.init(this); AudioAndHapticFeedbackManager.init(this); AccessibilityUtils.init(this); StatsUtils.init(this); checkForTransliteration();/*from w ww .java2s. co m*/ super.onCreate(); mHandler.onCreate(); DEBUG = DebugFlags.DEBUG_ENABLED; // TODO: Resolve mutual dependencies of {@link #loadSettings()} and {@link #initSuggest()}. loadSettings(); resetSuggest(); // Register to receive ringer mode change and network state change. // Also receive installation and removal of a dictionary pack. final IntentFilter filter = new IntentFilter(); //filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION); registerReceiver(mConnectivityAndRingerModeChangeReceiver, filter); final IntentFilter packageFilter = new IntentFilter(); packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED); packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); packageFilter.addDataScheme(SCHEME_PACKAGE); registerReceiver(mDictionaryPackInstallReceiver, packageFilter); final IntentFilter newDictFilter = new IntentFilter(); newDictFilter.addAction(DictionaryPackConstants.NEW_DICTIONARY_INTENT_ACTION); registerReceiver(mDictionaryPackInstallReceiver, newDictFilter); final IntentFilter dictDumpFilter = new IntentFilter(); dictDumpFilter.addAction(DictionaryDumpBroadcastReceiver.DICTIONARY_DUMP_INTENT_ACTION); registerReceiver(mDictionaryDumpBroadcastReceiver, dictDumpFilter); DictionaryDecayBroadcastReciever.setUpIntervalAlarmForDictionaryDecaying(this); StatsUtils.onCreate(mSettings.getCurrent()); }