安卓:从设备隐藏体积变化吧? [英] Android: Hide Volume change bar from device?

查看:116
本文介绍了安卓:从设备隐藏体积变化吧?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法隐藏的体积变化酒吧/通知(但是你可以称之为it..btw。你怎么称呼它?)?

is there a way to hide the volume change bar/notification (however you might call it..btw. how do you call it?) ?

我上面附着的截图。此栏显示每次我改变音量(至少我的Nexus测试设备上)。或者这是一个特殊的关系?

i attached a screenshot above. this bar is shown everytime i change the volume (at least on my nexus test device). or is this a nexus special?

推荐答案

有出现,当你preSS音量加/减键的默认后蜂窝音量滑块。
你不能把它隐藏在系统中的每一个画面,但你可以把它隐藏在你的活动。
这种添加到您想要隐藏它,然后手动更改卷的活动。或者你也可以什么都不做的情况下,KeyEvent.KEY code_VOLUME_UP / DOWN如果你不想改变音量。记住要返回true其中menans你消耗的活动。如果您返回false在那里你会得到双倍效果时,默认音量行为将您的code之后被触发。

It is the default post-honeycomb volume slider which appears when you press volume up/down buttons. You cannot hide it in every screen of the system, but you can hide it in your activities. Add this to an activity where you want to hide it and change the volume manually. Or you can just do nothing in case KeyEvent.KEYCODE_VOLUME_UP / DOWN if you don't want to change the volume. Remember to return true which menans you consumed the event. If you return false out there you will get double effect when the default volume behaviour will be triggered after your code.

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_VOLUME_UP:
            manager.adjustStreamVolume(AudioManager.STREAM_MUSIC,
                    AudioManager.ADJUST_RAISE,
                    AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
            return true;
        case KeyEvent.KEYCODE_VOLUME_DOWN:
            manager.adjustStreamVolume(AudioManager.STREAM_MUSIC,
                    AudioManager.ADJUST_LOWER,
                    AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
            return true;

        default:
            return super.onKeyDown(keyCode, event);
    }
}

在哪里AudioManager经理检索为

Where AudioManager manager is retrieved as

manager = (AudioManager) context
            .getSystemService(Context.AUDIO_SERVICE);

这篇关于安卓:从设备隐藏体积变化吧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆