当前位置: 首页>>代码示例>>Java>>正文


Java AudioManager.RINGER_MODE_CHANGED_ACTION属性代码示例

本文整理汇总了Java中android.media.AudioManager.RINGER_MODE_CHANGED_ACTION属性的典型用法代码示例。如果您正苦于以下问题:Java AudioManager.RINGER_MODE_CHANGED_ACTION属性的具体用法?Java AudioManager.RINGER_MODE_CHANGED_ACTION怎么用?Java AudioManager.RINGER_MODE_CHANGED_ACTION使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.media.AudioManager的用法示例。


在下文中一共展示了AudioManager.RINGER_MODE_CHANGED_ACTION属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    String event = null;
    String type = null;

    switch(intent.getAction()){
        case Intent.ACTION_SCREEN_OFF:
            event = DeviceEvent.EVENT_SCREEN_OFF;
            type = DeviceEvent.TYPE_SCREEN;
            break;

        case Intent.ACTION_SCREEN_ON:
            event = DeviceEvent.EVENT_SCREEN_ON;
            type = DeviceEvent.TYPE_SCREEN;
            break;

        case Intent.ACTION_USER_PRESENT:
            event = DeviceEvent.EVENT_SCREEN_USER_PRESENT;
            type = DeviceEvent.TYPE_SCREEN;
            break;

        case Intent.ACTION_BOOT_COMPLETED:
            event = DeviceEvent.EVENT_BOOT_COMPLETED;
            type = DeviceEvent.TYPE_BOOT;
            break;

        case Intent.ACTION_SHUTDOWN:
            event = DeviceEvent.EVENT_BOOT_SHUTDOWN;
            type = DeviceEvent.TYPE_BOOT;
            break;

        case Intent.ACTION_BATTERY_LOW:
            event = DeviceEvent.EVENT_BATTERY_LOW;
            type = DeviceEvent.TYPE_BATTERY;
            break;

        case Intent.ACTION_BATTERY_OKAY:
            event = DeviceEvent.EVENT_BATTERY_OKAY;
            type = DeviceEvent.TYPE_BATTERY;
            break;

        case Intent.ACTION_POWER_CONNECTED:
            event = DeviceEvent.EVENT_BATTERY_AC_CONNECTED;
            type = DeviceEvent.TYPE_BATTERY;
            break;

        case Intent.ACTION_POWER_DISCONNECTED:
            event = DeviceEvent.EVENT_BATTERY_AC_DISCONNECTED;
            type = DeviceEvent.TYPE_BATTERY;
            break;

        case AudioManager.RINGER_MODE_CHANGED_ACTION:
            AudioManager am = (AudioManager)getContext().getSystemService(Context.AUDIO_SERVICE);
            switch (am.getRingerMode()) {
                case AudioManager.RINGER_MODE_SILENT:
                    event = DeviceEvent.EVENT_RINGER_SILENT;
                    type = DeviceEvent.TYPE_RINGER;
                    break;

                case AudioManager.RINGER_MODE_VIBRATE:
                    event = DeviceEvent.EVENT_RINGER_VIBRATE;
                    type = DeviceEvent.TYPE_RINGER;
                    break;

                case AudioManager.RINGER_MODE_NORMAL:
                    event = DeviceEvent.EVENT_RINGER_NORMAL;
                    type = DeviceEvent.TYPE_RINGER;
                    break;
            }
        default:
            break;
    }

    if (type != null)
        output(new DeviceEvent(type, event));
}
 
开发者ID:PrivacyStreams,项目名称:PrivacyStreams,代码行数:76,代码来源:DeviceEventUpdatesProvider.java

示例2: registerReceiver

private void registerReceiver() {
    if (!mIsReceiving) {
        IntentFilter intentFilter = new IntentFilter(
                AudioManager.RINGER_MODE_CHANGED_ACTION);
        mContext.registerReceiver(mBroadcastReceiver, intentFilter);
        mSettingsObserver.observe();
        mIsReceiving = true;
        if (DEBUG) log(getKey() + ": receiver registered");
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:10,代码来源:RingerModeTile.java

示例3: onCreate

@Override
public void onCreate() {
    LatinImeLogger.init(this);
    KeyboardSwitcher.init(this);
    super.onCreate();
    //setStatusIcon(R.drawable.ime_qwerty);
    mResources = getResources();
    final Configuration conf = mResources.getConfiguration();
    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();
    }
    mReCorrectionEnabled = prefs.getBoolean(PREF_RECORRECTION_ENABLED,
            getResources().getBoolean(R.bool.default_recorrection_enabled));
    
    Log.d("KP2AK","finding plugin dicts...");
    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;
    initSuggestPuncList();

    // register to receive ringer mode changes for silent mode
    IntentFilter filter = new IntentFilter(AudioManager.RINGER_MODE_CHANGED_ACTION);
    registerReceiver(mReceiver, filter);
   
    prefs.registerOnSharedPreferenceChangeListener(this);
    
    //check if we have KP2A data available:
    mHadKp2aData = mShowKp2aKeyboard = keepass2android.kbbridge.KeyboardData.hasData();
    
    mClearKeyboardReceiver = new ClearKeyboardBroadcastReceiver();
    registerReceiver(mClearKeyboardReceiver, new IntentFilter(get_KEEPASS2ANDROID_KEYBOARD_CLEARED(this)));
    android.util.Log.d("KP2AK", "registered receiver for clear keyboard broadcast: "+get_KEEPASS2ANDROID_KEYBOARD_CLEARED(this));
    
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:61,代码来源:KP2AKeyboard.java


注:本文中的android.media.AudioManager.RINGER_MODE_CHANGED_ACTION属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。