Android – how to disable native toast messages

I am creating a remote application. One of the buttons on the remote control can adjust the volume up and down. I have this button on the remote control to do something different, because adjusting the volume in my application is of no great importance. So my question is:

Can I disable native toast messages in the application itself or in the device's firmware? I'm building my application into a custom ROM, so should I have full access to toast messages?

Thank you!

resolvent:

Take a look at AudioManager - > flag_ SHOW_ UI if you don't want to display local toast, please don't use this flag. Example of adjuststreamvolume

 AudioManager audio = (AudioManager) getSystemService(Context.AUdio_SERVICE);
 audio.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_SAME, flags); 

Edit: you can also listen to the hard volume button operation

 @Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)){
        //set Volume without toast flag
    }
    return true;
}

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>