Home > Mobile >  Android TV volume problem
Android TV volume problem

Time:09-21

Don't know what the hell a TV at home recently, the volume of the constant automatically jump to 0, not reduce to zero, is directly to 0, just don't show the volume and the panel, is suddenly didn't cry, and found that the volume is 0, all kinds of search on the net, can't find the problem, so had to change the way of thinking, jump 0, then automatically adjustable back to it,

1. The volume change information: the volume of the receiving system change event broadcast android. Media. VOLUME_CHANGED_ACTION, then obtain oldVolume from the broadcast intent and newVolume, that's easy

2. Set the volume: if newVolume==0 and differential value of 1 is set the volume to oldVolume,
Solution a: using automated software Macrodroid, receives the broadcast after the shell command to adjust the volume: "the media volume - stream3 - set 10", the result might be
Is the TV version of the media command is neutered, nima no volume,
Scheme 2: write an APP to do yourself, content is as follows:
This is the radio receiver code:
 public class VolumeReceiver extends BroadcastReceiver {

@ Override
Public void onReceive (Context Context, Intent Intent) {
//TODO: This method is called when the BroadcastReceiver is identifiers
//an Intent broadcast.

//Toast. MakeText (context, volume change, Toast. LENGTH_SHORT), show ();

Int oldVol=intent. GetIntExtra (" android. Media. EXTRA_PREV_VOLUME_STREAM_VALUE ", 1);
Int newVol=intent. GetIntExtra (" android. Media. EXTRA_VOLUME_STREAM_VALUE ", 1);
Int streamType=intent. GetIntExtra (" android. Media. EXTRA_VOLUME_STREAM_TYPE ", 1);

The d (" StreamType: "+ StreamType," after adjusting the volume: "+ newVol + (char) 10 +" to adjust volume: before "+ oldVol);
If (Math. Abs (oldVol - newVol) & gt; 1 & amp; & NewVol==0) {
//if (newVol==0) {
AudioManager AudioManager=(AudioManager) context. GetApplicationContext () getSystemService (context. AUDIO_SERVICE);
AudioManager. SetMode (audioManager. MODE_NORMAL);
AudioManager. SetStreamVolume (streamType, oldVol, audioManager. FLAG_PLAY_SOUND);
Toast. MakeText (context, "detect abnormal volume to zero, has automatic recovery", Toast. LENGTH_LONG), show ();
}
}
}

This is the listing file:
 & lt; ? The XML version="1.0" encoding="utf-8"?> 
XMLNS: tools="http://schemas.android.com/tools"
Package="com. Yangliu. Volmanager" & gt;


The android: required="false"/& gt;

Android: allowBackup="true"
The android: icon="@ mipmap/ic_launcher"
Android: label="@ string/app_name"
Android: roundIcon="@ mipmap/ic_launcher_round"
Android: supportsRtl="true"
Android: theme="@ android: style/theme. NoDisplay"
Tools: ignore="GoogleAppIndexingWarning" & gt;
The android: name=". BootReceiver "
Android: enabled="true"
Android: exported="true" & gt;









The android: name=". VolumeReceiver "
Android: enabled="true"
Android: exported="true" & gt;





The main code that's all,
Results: log records show that the volume value is change back, but the fact is sound or not, the volume on the front panel value is turned back, but as long as the press the remote control volume + again, becomes a progress bar, that is to say, the original is 0, strange is, seek expert advice,

Solution of a problem have a solution? Scheme 2 what's the problem? How to solve?

CodePudding user response:

Is there a great god to solve ah

CodePudding user response:

Add that the television is the android 4.4,

CodePudding user response:

MAudioManager=(AudioManager) getSystemService (AUDIO_SERVICE);
Set up the voice below
MAudioManager. SetStreamVolume (AudioManager. STREAM_MUSIC mCurrentVolume, 0).
Mute is as follows:
MAudioManager. SetStreamVolume (AudioManager. STREAM_MUSIC, 0, 0).
The current volume is as follows:

Volume=mAudioManager. GetStreamVolume (AudioManager. STREAM_MUSIC);

The above is the volume of the player in multiple android 4.4 solution control code;

CodePudding user response:

The
reference fai _alexxm reply: 3/f
mAudioManager=(AudioManager) getSystemService (AUDIO_SERVICE);
Set up the voice below
MAudioManager. SetStreamVolume (AudioManager. STREAM_MUSIC mCurrentVolume, 0).
Mute is as follows:
MAudioManager. SetStreamVolume (AudioManager. STREAM_MUSIC, 0, 0).
The current volume is as follows:

Volume=mAudioManager. GetStreamVolume (AudioManager. STREAM_MUSIC);

The above is the volume of the player in multiple android 4.4 solution control code;

No difference with my code

CodePudding user response:

I suggest to change a TV
  • Related