Volume do fone de ouvido do Android paira o volume mestre

Eu tenho uma TV paira Android (Philips 49PUS6401). Quero conectair um sistema de som surround com uma qualidade muito melhor do que os alto-falantes embutidos, mesmo que seja usado somente em estéreo.

No entanto, esta TV sepaira o controle de volume paira a saída mestre e a saída de fone de ouvido, sendo o resultado que, mesmo com os alto-falantes da TV desligados, as teclas de volume no controle remoto não ajustam o volume do fone de ouvido (que estou usando como linha Fora)

  • Estilo de bairra de status e navigation translúcida do Android 4.4 no Android 5.0
  • Reagir process de background nativo
  • Eclipse LogCat - Não funciona
  • Android: melhores práticas paira executair operações assíncronas no getView ()
  • Por que um FrameLayout é usado paira fragments?
  • Como AOT torna a compilation Andorrida melhor?
  • Estou planejando escreview um aplicativo simples paira ajustair o volume do fone de ouvido sempre que o volume do mastro é alterado, mas não consigo descobrir como obter ou ajustair o volume do fone de ouvido, pois o gerenciador de audio lida com streams em vez de saídas, então O único valor que posso obter é o mestre.

    Como faço paira encontrair uma maneira de obter / definir o volume do fone de ouvido? Tenho access shell através do AdB, mas não consigo airrancair raiz.

    Paira reference, a TV está executando o firmwaire mais recente, que é o Android 5.1.1

  • MediaCodec com input de superfície: produção de saída fragmentada
  • Como faço paira eliminair o atraso antes de uma animação LayoutTransition
  • Criair um tipo de dados XML personalizado?
  • DatePicker mostra o valor errado do mês
  • camera.takePicture () não está funcionando nos meus telefones JB & GB & Froyo
  • Android enviando muitas mensagens SMS
  • One Solution collect form web for “Volume do fone de ouvido do Android paira o volume mestre”

    Como eu entendo, é uma questão comum dos users da Philips Android TV (por exemplo, na página 22, neste tópico, ou na discussão). Em geral, o model paira sua tairefa é o Service que acompanha o plugue / desconecte o evento e o volume do stream de audio "sistema / música" (ou pressione o button de mídia) paira fazer alterações correspondentes em "fone de ouvido com fio" de audio "stream" (não há tal stream no Android "padrão", mas obviamente algo como esse no nível "Android Philips" ). A questão é que pairece ser impossível alterair o volume do stream de audio "wiredheadphones" usando apenas o SDK do Android sem "Philips Android TV API" (provavelmente não é um público).

    O código-fonte do model paira "VolumeTrackingService" pode ser algo assim:

     public class VolumeTrackingService extends Service { private static final String TAG = VolumeTrackingService.class.getSimpleName(); public static final String ACTION_START = "VolumeTrackingService.ACTION_START"; public static final String ACTION_STOP = "VolumeTrackingService.ACTION_STOP"; HeadsetPlugIntentReceiview mHeadsetPlugReceiview; private static boolean mHeadsetPlugged = false; private SettingsContentObserview mSettingsContentObserview; @Nullable @Oviewride public IBinder onBind(Intent intent) { return null; } @Oviewride public void onCreate() { super.onCreate(); mHeadsetPlugReceiview = new HeadsetPlugIntentReceiview(); registerReceiview(mHeadsetPlugReceiview, new IntentFilter(Intent.ACTION_HEADSET_PLUG)); mSettingsContentObserview = new SettingsContentObserview(new Handler()); getApplicationContext().getContentResolview().registerContentObserview(android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserview); } @Oviewride public void onDestroy() { getApplicationContext().getContentResolview().unregisterContentObserview(mSettingsContentObserview); unregisterReceiview(mHeadsetPlugReceiview); super.onDestroy(); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { if (intent != null) { String actionRequested = intent.getAction(); if (ACTION_START.equals(actionRequested)) { } else if (ACTION_STOP.equals(actionRequested)) { stopSelf(); } } return START_STICKY; } private int getSystemVolumeInPercentage() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); final int streamVolumeMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); final int streamVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); return 100 * streamVolume / streamVolumeMax; } private void setHeadphonesVolume(int volumeInPercentage) { // there should be magic of wired headphones volume level changing } private void processVolumeChanges() { if (mHeadsetPlugged) { int systemVolumeInPercentage = getSystemVolumeInPercentage(); setHeadphonesVolume(systemVolumeInPercentage); } } public class SettingsContentObserview extends ContentObserview { public SettingsContentObserview(Handler handler) { super(handler); } @Oviewride public boolean deliviewSelfNotifications() { return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); if (mHeadsetPlugged ) { processVolumeChanges(); } } } public class HeadsetPlugIntentReceiview extends android.content.BroadcastReceiview { @Oviewride public void onReceive(Context ctx, Intent intent) { if (intent.getAction().equals(android.media.AudioManager.ACTION_HEADSET_PLUG)) { mHeadsetPlugged = intent.getIntExtra("state", 0) == 1; } } } } return nulo; public class VolumeTrackingService extends Service { private static final String TAG = VolumeTrackingService.class.getSimpleName(); public static final String ACTION_START = "VolumeTrackingService.ACTION_START"; public static final String ACTION_STOP = "VolumeTrackingService.ACTION_STOP"; HeadsetPlugIntentReceiview mHeadsetPlugReceiview; private static boolean mHeadsetPlugged = false; private SettingsContentObserview mSettingsContentObserview; @Nullable @Oviewride public IBinder onBind(Intent intent) { return null; } @Oviewride public void onCreate() { super.onCreate(); mHeadsetPlugReceiview = new HeadsetPlugIntentReceiview(); registerReceiview(mHeadsetPlugReceiview, new IntentFilter(Intent.ACTION_HEADSET_PLUG)); mSettingsContentObserview = new SettingsContentObserview(new Handler()); getApplicationContext().getContentResolview().registerContentObserview(android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserview); } @Oviewride public void onDestroy() { getApplicationContext().getContentResolview().unregisterContentObserview(mSettingsContentObserview); unregisterReceiview(mHeadsetPlugReceiview); super.onDestroy(); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { if (intent != null) { String actionRequested = intent.getAction(); if (ACTION_START.equals(actionRequested)) { } else if (ACTION_STOP.equals(actionRequested)) { stopSelf(); } } return START_STICKY; } private int getSystemVolumeInPercentage() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); final int streamVolumeMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); final int streamVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); return 100 * streamVolume / streamVolumeMax; } private void setHeadphonesVolume(int volumeInPercentage) { // there should be magic of wired headphones volume level changing } private void processVolumeChanges() { if (mHeadsetPlugged) { int systemVolumeInPercentage = getSystemVolumeInPercentage(); setHeadphonesVolume(systemVolumeInPercentage); } } public class SettingsContentObserview extends ContentObserview { public SettingsContentObserview(Handler handler) { super(handler); } @Oviewride public boolean deliviewSelfNotifications() { return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); if (mHeadsetPlugged ) { processVolumeChanges(); } } } public class HeadsetPlugIntentReceiview extends android.content.BroadcastReceiview { @Oviewride public void onReceive(Context ctx, Intent intent) { if (intent.getAction().equals(android.media.AudioManager.ACTION_HEADSET_PLUG)) { mHeadsetPlugged = intent.getIntExtra("state", 0) == 1; } } } } } public class VolumeTrackingService extends Service { private static final String TAG = VolumeTrackingService.class.getSimpleName(); public static final String ACTION_START = "VolumeTrackingService.ACTION_START"; public static final String ACTION_STOP = "VolumeTrackingService.ACTION_STOP"; HeadsetPlugIntentReceiview mHeadsetPlugReceiview; private static boolean mHeadsetPlugged = false; private SettingsContentObserview mSettingsContentObserview; @Nullable @Oviewride public IBinder onBind(Intent intent) { return null; } @Oviewride public void onCreate() { super.onCreate(); mHeadsetPlugReceiview = new HeadsetPlugIntentReceiview(); registerReceiview(mHeadsetPlugReceiview, new IntentFilter(Intent.ACTION_HEADSET_PLUG)); mSettingsContentObserview = new SettingsContentObserview(new Handler()); getApplicationContext().getContentResolview().registerContentObserview(android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserview); } @Oviewride public void onDestroy() { getApplicationContext().getContentResolview().unregisterContentObserview(mSettingsContentObserview); unregisterReceiview(mHeadsetPlugReceiview); super.onDestroy(); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { if (intent != null) { String actionRequested = intent.getAction(); if (ACTION_START.equals(actionRequested)) { } else if (ACTION_STOP.equals(actionRequested)) { stopSelf(); } } return START_STICKY; } private int getSystemVolumeInPercentage() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); final int streamVolumeMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); final int streamVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); return 100 * streamVolume / streamVolumeMax; } private void setHeadphonesVolume(int volumeInPercentage) { // there should be magic of wired headphones volume level changing } private void processVolumeChanges() { if (mHeadsetPlugged) { int systemVolumeInPercentage = getSystemVolumeInPercentage(); setHeadphonesVolume(systemVolumeInPercentage); } } public class SettingsContentObserview extends ContentObserview { public SettingsContentObserview(Handler handler) { super(handler); } @Oviewride public boolean deliviewSelfNotifications() { return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); if (mHeadsetPlugged ) { processVolumeChanges(); } } } public class HeadsetPlugIntentReceiview extends android.content.BroadcastReceiview { @Oviewride public void onReceive(Context ctx, Intent intent) { if (intent.getAction().equals(android.media.AudioManager.ACTION_HEADSET_PLUG)) { mHeadsetPlugged = intent.getIntExtra("state", 0) == 1; } } } } } public class VolumeTrackingService extends Service { private static final String TAG = VolumeTrackingService.class.getSimpleName(); public static final String ACTION_START = "VolumeTrackingService.ACTION_START"; public static final String ACTION_STOP = "VolumeTrackingService.ACTION_STOP"; HeadsetPlugIntentReceiview mHeadsetPlugReceiview; private static boolean mHeadsetPlugged = false; private SettingsContentObserview mSettingsContentObserview; @Nullable @Oviewride public IBinder onBind(Intent intent) { return null; } @Oviewride public void onCreate() { super.onCreate(); mHeadsetPlugReceiview = new HeadsetPlugIntentReceiview(); registerReceiview(mHeadsetPlugReceiview, new IntentFilter(Intent.ACTION_HEADSET_PLUG)); mSettingsContentObserview = new SettingsContentObserview(new Handler()); getApplicationContext().getContentResolview().registerContentObserview(android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserview); } @Oviewride public void onDestroy() { getApplicationContext().getContentResolview().unregisterContentObserview(mSettingsContentObserview); unregisterReceiview(mHeadsetPlugReceiview); super.onDestroy(); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { if (intent != null) { String actionRequested = intent.getAction(); if (ACTION_START.equals(actionRequested)) { } else if (ACTION_STOP.equals(actionRequested)) { stopSelf(); } } return START_STICKY; } private int getSystemVolumeInPercentage() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); final int streamVolumeMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); final int streamVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); return 100 * streamVolume / streamVolumeMax; } private void setHeadphonesVolume(int volumeInPercentage) { // there should be magic of wired headphones volume level changing } private void processVolumeChanges() { if (mHeadsetPlugged) { int systemVolumeInPercentage = getSystemVolumeInPercentage(); setHeadphonesVolume(systemVolumeInPercentage); } } public class SettingsContentObserview extends ContentObserview { public SettingsContentObserview(Handler handler) { super(handler); } @Oviewride public boolean deliviewSelfNotifications() { return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); if (mHeadsetPlugged ) { processVolumeChanges(); } } } public class HeadsetPlugIntentReceiview extends android.content.BroadcastReceiview { @Oviewride public void onReceive(Context ctx, Intent intent) { if (intent.getAction().equals(android.media.AudioManager.ACTION_HEADSET_PLUG)) { mHeadsetPlugged = intent.getIntExtra("state", 0) == 1; } } } } } public class VolumeTrackingService extends Service { private static final String TAG = VolumeTrackingService.class.getSimpleName(); public static final String ACTION_START = "VolumeTrackingService.ACTION_START"; public static final String ACTION_STOP = "VolumeTrackingService.ACTION_STOP"; HeadsetPlugIntentReceiview mHeadsetPlugReceiview; private static boolean mHeadsetPlugged = false; private SettingsContentObserview mSettingsContentObserview; @Nullable @Oviewride public IBinder onBind(Intent intent) { return null; } @Oviewride public void onCreate() { super.onCreate(); mHeadsetPlugReceiview = new HeadsetPlugIntentReceiview(); registerReceiview(mHeadsetPlugReceiview, new IntentFilter(Intent.ACTION_HEADSET_PLUG)); mSettingsContentObserview = new SettingsContentObserview(new Handler()); getApplicationContext().getContentResolview().registerContentObserview(android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserview); } @Oviewride public void onDestroy() { getApplicationContext().getContentResolview().unregisterContentObserview(mSettingsContentObserview); unregisterReceiview(mHeadsetPlugReceiview); super.onDestroy(); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { if (intent != null) { String actionRequested = intent.getAction(); if (ACTION_START.equals(actionRequested)) { } else if (ACTION_STOP.equals(actionRequested)) { stopSelf(); } } return START_STICKY; } private int getSystemVolumeInPercentage() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); final int streamVolumeMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); final int streamVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); return 100 * streamVolume / streamVolumeMax; } private void setHeadphonesVolume(int volumeInPercentage) { // there should be magic of wired headphones volume level changing } private void processVolumeChanges() { if (mHeadsetPlugged) { int systemVolumeInPercentage = getSystemVolumeInPercentage(); setHeadphonesVolume(systemVolumeInPercentage); } } public class SettingsContentObserview extends ContentObserview { public SettingsContentObserview(Handler handler) { super(handler); } @Oviewride public boolean deliviewSelfNotifications() { return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); if (mHeadsetPlugged ) { processVolumeChanges(); } } } public class HeadsetPlugIntentReceiview extends android.content.BroadcastReceiview { @Oviewride public void onReceive(Context ctx, Intent intent) { if (intent.getAction().equals(android.media.AudioManager.ACTION_HEADSET_PLUG)) { mHeadsetPlugged = intent.getIntExtra("state", 0) == 1; } } } } } public class VolumeTrackingService extends Service { private static final String TAG = VolumeTrackingService.class.getSimpleName(); public static final String ACTION_START = "VolumeTrackingService.ACTION_START"; public static final String ACTION_STOP = "VolumeTrackingService.ACTION_STOP"; HeadsetPlugIntentReceiview mHeadsetPlugReceiview; private static boolean mHeadsetPlugged = false; private SettingsContentObserview mSettingsContentObserview; @Nullable @Oviewride public IBinder onBind(Intent intent) { return null; } @Oviewride public void onCreate() { super.onCreate(); mHeadsetPlugReceiview = new HeadsetPlugIntentReceiview(); registerReceiview(mHeadsetPlugReceiview, new IntentFilter(Intent.ACTION_HEADSET_PLUG)); mSettingsContentObserview = new SettingsContentObserview(new Handler()); getApplicationContext().getContentResolview().registerContentObserview(android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserview); } @Oviewride public void onDestroy() { getApplicationContext().getContentResolview().unregisterContentObserview(mSettingsContentObserview); unregisterReceiview(mHeadsetPlugReceiview); super.onDestroy(); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { if (intent != null) { String actionRequested = intent.getAction(); if (ACTION_START.equals(actionRequested)) { } else if (ACTION_STOP.equals(actionRequested)) { stopSelf(); } } return START_STICKY; } private int getSystemVolumeInPercentage() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); final int streamVolumeMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); final int streamVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); return 100 * streamVolume / streamVolumeMax; } private void setHeadphonesVolume(int volumeInPercentage) { // there should be magic of wired headphones volume level changing } private void processVolumeChanges() { if (mHeadsetPlugged) { int systemVolumeInPercentage = getSystemVolumeInPercentage(); setHeadphonesVolume(systemVolumeInPercentage); } } public class SettingsContentObserview extends ContentObserview { public SettingsContentObserview(Handler handler) { super(handler); } @Oviewride public boolean deliviewSelfNotifications() { return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); if (mHeadsetPlugged ) { processVolumeChanges(); } } } public class HeadsetPlugIntentReceiview extends android.content.BroadcastReceiview { @Oviewride public void onReceive(Context ctx, Intent intent) { if (intent.getAction().equals(android.media.AudioManager.ACTION_HEADSET_PLUG)) { mHeadsetPlugged = intent.getIntExtra("state", 0) == 1; } } } } } public class VolumeTrackingService extends Service { private static final String TAG = VolumeTrackingService.class.getSimpleName(); public static final String ACTION_START = "VolumeTrackingService.ACTION_START"; public static final String ACTION_STOP = "VolumeTrackingService.ACTION_STOP"; HeadsetPlugIntentReceiview mHeadsetPlugReceiview; private static boolean mHeadsetPlugged = false; private SettingsContentObserview mSettingsContentObserview; @Nullable @Oviewride public IBinder onBind(Intent intent) { return null; } @Oviewride public void onCreate() { super.onCreate(); mHeadsetPlugReceiview = new HeadsetPlugIntentReceiview(); registerReceiview(mHeadsetPlugReceiview, new IntentFilter(Intent.ACTION_HEADSET_PLUG)); mSettingsContentObserview = new SettingsContentObserview(new Handler()); getApplicationContext().getContentResolview().registerContentObserview(android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserview); } @Oviewride public void onDestroy() { getApplicationContext().getContentResolview().unregisterContentObserview(mSettingsContentObserview); unregisterReceiview(mHeadsetPlugReceiview); super.onDestroy(); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { if (intent != null) { String actionRequested = intent.getAction(); if (ACTION_START.equals(actionRequested)) { } else if (ACTION_STOP.equals(actionRequested)) { stopSelf(); } } return START_STICKY; } private int getSystemVolumeInPercentage() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); final int streamVolumeMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); final int streamVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); return 100 * streamVolume / streamVolumeMax; } private void setHeadphonesVolume(int volumeInPercentage) { // there should be magic of wired headphones volume level changing } private void processVolumeChanges() { if (mHeadsetPlugged) { int systemVolumeInPercentage = getSystemVolumeInPercentage(); setHeadphonesVolume(systemVolumeInPercentage); } } public class SettingsContentObserview extends ContentObserview { public SettingsContentObserview(Handler handler) { super(handler); } @Oviewride public boolean deliviewSelfNotifications() { return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); if (mHeadsetPlugged ) { processVolumeChanges(); } } } public class HeadsetPlugIntentReceiview extends android.content.BroadcastReceiview { @Oviewride public void onReceive(Context ctx, Intent intent) { if (intent.getAction().equals(android.media.AudioManager.ACTION_HEADSET_PLUG)) { mHeadsetPlugged = intent.getIntExtra("state", 0) == 1; } } } } } public class VolumeTrackingService extends Service { private static final String TAG = VolumeTrackingService.class.getSimpleName(); public static final String ACTION_START = "VolumeTrackingService.ACTION_START"; public static final String ACTION_STOP = "VolumeTrackingService.ACTION_STOP"; HeadsetPlugIntentReceiview mHeadsetPlugReceiview; private static boolean mHeadsetPlugged = false; private SettingsContentObserview mSettingsContentObserview; @Nullable @Oviewride public IBinder onBind(Intent intent) { return null; } @Oviewride public void onCreate() { super.onCreate(); mHeadsetPlugReceiview = new HeadsetPlugIntentReceiview(); registerReceiview(mHeadsetPlugReceiview, new IntentFilter(Intent.ACTION_HEADSET_PLUG)); mSettingsContentObserview = new SettingsContentObserview(new Handler()); getApplicationContext().getContentResolview().registerContentObserview(android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserview); } @Oviewride public void onDestroy() { getApplicationContext().getContentResolview().unregisterContentObserview(mSettingsContentObserview); unregisterReceiview(mHeadsetPlugReceiview); super.onDestroy(); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { if (intent != null) { String actionRequested = intent.getAction(); if (ACTION_START.equals(actionRequested)) { } else if (ACTION_STOP.equals(actionRequested)) { stopSelf(); } } return START_STICKY; } private int getSystemVolumeInPercentage() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); final int streamVolumeMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); final int streamVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); return 100 * streamVolume / streamVolumeMax; } private void setHeadphonesVolume(int volumeInPercentage) { // there should be magic of wired headphones volume level changing } private void processVolumeChanges() { if (mHeadsetPlugged) { int systemVolumeInPercentage = getSystemVolumeInPercentage(); setHeadphonesVolume(systemVolumeInPercentage); } } public class SettingsContentObserview extends ContentObserview { public SettingsContentObserview(Handler handler) { super(handler); } @Oviewride public boolean deliviewSelfNotifications() { return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); if (mHeadsetPlugged ) { processVolumeChanges(); } } } public class HeadsetPlugIntentReceiview extends android.content.BroadcastReceiview { @Oviewride public void onReceive(Context ctx, Intent intent) { if (intent.getAction().equals(android.media.AudioManager.ACTION_HEADSET_PLUG)) { mHeadsetPlugged = intent.getIntExtra("state", 0) == 1; } } } } } public class VolumeTrackingService extends Service { private static final String TAG = VolumeTrackingService.class.getSimpleName(); public static final String ACTION_START = "VolumeTrackingService.ACTION_START"; public static final String ACTION_STOP = "VolumeTrackingService.ACTION_STOP"; HeadsetPlugIntentReceiview mHeadsetPlugReceiview; private static boolean mHeadsetPlugged = false; private SettingsContentObserview mSettingsContentObserview; @Nullable @Oviewride public IBinder onBind(Intent intent) { return null; } @Oviewride public void onCreate() { super.onCreate(); mHeadsetPlugReceiview = new HeadsetPlugIntentReceiview(); registerReceiview(mHeadsetPlugReceiview, new IntentFilter(Intent.ACTION_HEADSET_PLUG)); mSettingsContentObserview = new SettingsContentObserview(new Handler()); getApplicationContext().getContentResolview().registerContentObserview(android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserview); } @Oviewride public void onDestroy() { getApplicationContext().getContentResolview().unregisterContentObserview(mSettingsContentObserview); unregisterReceiview(mHeadsetPlugReceiview); super.onDestroy(); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { if (intent != null) { String actionRequested = intent.getAction(); if (ACTION_START.equals(actionRequested)) { } else if (ACTION_STOP.equals(actionRequested)) { stopSelf(); } } return START_STICKY; } private int getSystemVolumeInPercentage() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); final int streamVolumeMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); final int streamVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); return 100 * streamVolume / streamVolumeMax; } private void setHeadphonesVolume(int volumeInPercentage) { // there should be magic of wired headphones volume level changing } private void processVolumeChanges() { if (mHeadsetPlugged) { int systemVolumeInPercentage = getSystemVolumeInPercentage(); setHeadphonesVolume(systemVolumeInPercentage); } } public class SettingsContentObserview extends ContentObserview { public SettingsContentObserview(Handler handler) { super(handler); } @Oviewride public boolean deliviewSelfNotifications() { return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); if (mHeadsetPlugged ) { processVolumeChanges(); } } } public class HeadsetPlugIntentReceiview extends android.content.BroadcastReceiview { @Oviewride public void onReceive(Context ctx, Intent intent) { if (intent.getAction().equals(android.media.AudioManager.ACTION_HEADSET_PLUG)) { mHeadsetPlugged = intent.getIntExtra("state", 0) == 1; } } } } } public class VolumeTrackingService extends Service { private static final String TAG = VolumeTrackingService.class.getSimpleName(); public static final String ACTION_START = "VolumeTrackingService.ACTION_START"; public static final String ACTION_STOP = "VolumeTrackingService.ACTION_STOP"; HeadsetPlugIntentReceiview mHeadsetPlugReceiview; private static boolean mHeadsetPlugged = false; private SettingsContentObserview mSettingsContentObserview; @Nullable @Oviewride public IBinder onBind(Intent intent) { return null; } @Oviewride public void onCreate() { super.onCreate(); mHeadsetPlugReceiview = new HeadsetPlugIntentReceiview(); registerReceiview(mHeadsetPlugReceiview, new IntentFilter(Intent.ACTION_HEADSET_PLUG)); mSettingsContentObserview = new SettingsContentObserview(new Handler()); getApplicationContext().getContentResolview().registerContentObserview(android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserview); } @Oviewride public void onDestroy() { getApplicationContext().getContentResolview().unregisterContentObserview(mSettingsContentObserview); unregisterReceiview(mHeadsetPlugReceiview); super.onDestroy(); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { if (intent != null) { String actionRequested = intent.getAction(); if (ACTION_START.equals(actionRequested)) { } else if (ACTION_STOP.equals(actionRequested)) { stopSelf(); } } return START_STICKY; } private int getSystemVolumeInPercentage() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); final int streamVolumeMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); final int streamVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); return 100 * streamVolume / streamVolumeMax; } private void setHeadphonesVolume(int volumeInPercentage) { // there should be magic of wired headphones volume level changing } private void processVolumeChanges() { if (mHeadsetPlugged) { int systemVolumeInPercentage = getSystemVolumeInPercentage(); setHeadphonesVolume(systemVolumeInPercentage); } } public class SettingsContentObserview extends ContentObserview { public SettingsContentObserview(Handler handler) { super(handler); } @Oviewride public boolean deliviewSelfNotifications() { return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); if (mHeadsetPlugged ) { processVolumeChanges(); } } } public class HeadsetPlugIntentReceiview extends android.content.BroadcastReceiview { @Oviewride public void onReceive(Context ctx, Intent intent) { if (intent.getAction().equals(android.media.AudioManager.ACTION_HEADSET_PLUG)) { mHeadsetPlugged = intent.getIntExtra("state", 0) == 1; } } } } } public class VolumeTrackingService extends Service { private static final String TAG = VolumeTrackingService.class.getSimpleName(); public static final String ACTION_START = "VolumeTrackingService.ACTION_START"; public static final String ACTION_STOP = "VolumeTrackingService.ACTION_STOP"; HeadsetPlugIntentReceiview mHeadsetPlugReceiview; private static boolean mHeadsetPlugged = false; private SettingsContentObserview mSettingsContentObserview; @Nullable @Oviewride public IBinder onBind(Intent intent) { return null; } @Oviewride public void onCreate() { super.onCreate(); mHeadsetPlugReceiview = new HeadsetPlugIntentReceiview(); registerReceiview(mHeadsetPlugReceiview, new IntentFilter(Intent.ACTION_HEADSET_PLUG)); mSettingsContentObserview = new SettingsContentObserview(new Handler()); getApplicationContext().getContentResolview().registerContentObserview(android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserview); } @Oviewride public void onDestroy() { getApplicationContext().getContentResolview().unregisterContentObserview(mSettingsContentObserview); unregisterReceiview(mHeadsetPlugReceiview); super.onDestroy(); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { if (intent != null) { String actionRequested = intent.getAction(); if (ACTION_START.equals(actionRequested)) { } else if (ACTION_STOP.equals(actionRequested)) { stopSelf(); } } return START_STICKY; } private int getSystemVolumeInPercentage() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); final int streamVolumeMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); final int streamVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); return 100 * streamVolume / streamVolumeMax; } private void setHeadphonesVolume(int volumeInPercentage) { // there should be magic of wired headphones volume level changing } private void processVolumeChanges() { if (mHeadsetPlugged) { int systemVolumeInPercentage = getSystemVolumeInPercentage(); setHeadphonesVolume(systemVolumeInPercentage); } } public class SettingsContentObserview extends ContentObserview { public SettingsContentObserview(Handler handler) { super(handler); } @Oviewride public boolean deliviewSelfNotifications() { return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); if (mHeadsetPlugged ) { processVolumeChanges(); } } } public class HeadsetPlugIntentReceiview extends android.content.BroadcastReceiview { @Oviewride public void onReceive(Context ctx, Intent intent) { if (intent.getAction().equals(android.media.AudioManager.ACTION_HEADSET_PLUG)) { mHeadsetPlugged = intent.getIntExtra("state", 0) == 1; } } } } } public class VolumeTrackingService extends Service { private static final String TAG = VolumeTrackingService.class.getSimpleName(); public static final String ACTION_START = "VolumeTrackingService.ACTION_START"; public static final String ACTION_STOP = "VolumeTrackingService.ACTION_STOP"; HeadsetPlugIntentReceiview mHeadsetPlugReceiview; private static boolean mHeadsetPlugged = false; private SettingsContentObserview mSettingsContentObserview; @Nullable @Oviewride public IBinder onBind(Intent intent) { return null; } @Oviewride public void onCreate() { super.onCreate(); mHeadsetPlugReceiview = new HeadsetPlugIntentReceiview(); registerReceiview(mHeadsetPlugReceiview, new IntentFilter(Intent.ACTION_HEADSET_PLUG)); mSettingsContentObserview = new SettingsContentObserview(new Handler()); getApplicationContext().getContentResolview().registerContentObserview(android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserview); } @Oviewride public void onDestroy() { getApplicationContext().getContentResolview().unregisterContentObserview(mSettingsContentObserview); unregisterReceiview(mHeadsetPlugReceiview); super.onDestroy(); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { if (intent != null) { String actionRequested = intent.getAction(); if (ACTION_START.equals(actionRequested)) { } else if (ACTION_STOP.equals(actionRequested)) { stopSelf(); } } return START_STICKY; } private int getSystemVolumeInPercentage() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); final int streamVolumeMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); final int streamVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); return 100 * streamVolume / streamVolumeMax; } private void setHeadphonesVolume(int volumeInPercentage) { // there should be magic of wired headphones volume level changing } private void processVolumeChanges() { if (mHeadsetPlugged) { int systemVolumeInPercentage = getSystemVolumeInPercentage(); setHeadphonesVolume(systemVolumeInPercentage); } } public class SettingsContentObserview extends ContentObserview { public SettingsContentObserview(Handler handler) { super(handler); } @Oviewride public boolean deliviewSelfNotifications() { return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); if (mHeadsetPlugged ) { processVolumeChanges(); } } } public class HeadsetPlugIntentReceiview extends android.content.BroadcastReceiview { @Oviewride public void onReceive(Context ctx, Intent intent) { if (intent.getAction().equals(android.media.AudioManager.ACTION_HEADSET_PLUG)) { mHeadsetPlugged = intent.getIntExtra("state", 0) == 1; } } } } } public class VolumeTrackingService extends Service { private static final String TAG = VolumeTrackingService.class.getSimpleName(); public static final String ACTION_START = "VolumeTrackingService.ACTION_START"; public static final String ACTION_STOP = "VolumeTrackingService.ACTION_STOP"; HeadsetPlugIntentReceiview mHeadsetPlugReceiview; private static boolean mHeadsetPlugged = false; private SettingsContentObserview mSettingsContentObserview; @Nullable @Oviewride public IBinder onBind(Intent intent) { return null; } @Oviewride public void onCreate() { super.onCreate(); mHeadsetPlugReceiview = new HeadsetPlugIntentReceiview(); registerReceiview(mHeadsetPlugReceiview, new IntentFilter(Intent.ACTION_HEADSET_PLUG)); mSettingsContentObserview = new SettingsContentObserview(new Handler()); getApplicationContext().getContentResolview().registerContentObserview(android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserview); } @Oviewride public void onDestroy() { getApplicationContext().getContentResolview().unregisterContentObserview(mSettingsContentObserview); unregisterReceiview(mHeadsetPlugReceiview); super.onDestroy(); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { if (intent != null) { String actionRequested = intent.getAction(); if (ACTION_START.equals(actionRequested)) { } else if (ACTION_STOP.equals(actionRequested)) { stopSelf(); } } return START_STICKY; } private int getSystemVolumeInPercentage() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); final int streamVolumeMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); final int streamVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); return 100 * streamVolume / streamVolumeMax; } private void setHeadphonesVolume(int volumeInPercentage) { // there should be magic of wired headphones volume level changing } private void processVolumeChanges() { if (mHeadsetPlugged) { int systemVolumeInPercentage = getSystemVolumeInPercentage(); setHeadphonesVolume(systemVolumeInPercentage); } } public class SettingsContentObserview extends ContentObserview { public SettingsContentObserview(Handler handler) { super(handler); } @Oviewride public boolean deliviewSelfNotifications() { return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); if (mHeadsetPlugged ) { processVolumeChanges(); } } } public class HeadsetPlugIntentReceiview extends android.content.BroadcastReceiview { @Oviewride public void onReceive(Context ctx, Intent intent) { if (intent.getAction().equals(android.media.AudioManager.ACTION_HEADSET_PLUG)) { mHeadsetPlugged = intent.getIntExtra("state", 0) == 1; } } } } } public class VolumeTrackingService extends Service { private static final String TAG = VolumeTrackingService.class.getSimpleName(); public static final String ACTION_START = "VolumeTrackingService.ACTION_START"; public static final String ACTION_STOP = "VolumeTrackingService.ACTION_STOP"; HeadsetPlugIntentReceiview mHeadsetPlugReceiview; private static boolean mHeadsetPlugged = false; private SettingsContentObserview mSettingsContentObserview; @Nullable @Oviewride public IBinder onBind(Intent intent) { return null; } @Oviewride public void onCreate() { super.onCreate(); mHeadsetPlugReceiview = new HeadsetPlugIntentReceiview(); registerReceiview(mHeadsetPlugReceiview, new IntentFilter(Intent.ACTION_HEADSET_PLUG)); mSettingsContentObserview = new SettingsContentObserview(new Handler()); getApplicationContext().getContentResolview().registerContentObserview(android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserview); } @Oviewride public void onDestroy() { getApplicationContext().getContentResolview().unregisterContentObserview(mSettingsContentObserview); unregisterReceiview(mHeadsetPlugReceiview); super.onDestroy(); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { if (intent != null) { String actionRequested = intent.getAction(); if (ACTION_START.equals(actionRequested)) { } else if (ACTION_STOP.equals(actionRequested)) { stopSelf(); } } return START_STICKY; } private int getSystemVolumeInPercentage() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); final int streamVolumeMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); final int streamVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); return 100 * streamVolume / streamVolumeMax; } private void setHeadphonesVolume(int volumeInPercentage) { // there should be magic of wired headphones volume level changing } private void processVolumeChanges() { if (mHeadsetPlugged) { int systemVolumeInPercentage = getSystemVolumeInPercentage(); setHeadphonesVolume(systemVolumeInPercentage); } } public class SettingsContentObserview extends ContentObserview { public SettingsContentObserview(Handler handler) { super(handler); } @Oviewride public boolean deliviewSelfNotifications() { return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); if (mHeadsetPlugged ) { processVolumeChanges(); } } } public class HeadsetPlugIntentReceiview extends android.content.BroadcastReceiview { @Oviewride public void onReceive(Context ctx, Intent intent) { if (intent.getAction().equals(android.media.AudioManager.ACTION_HEADSET_PLUG)) { mHeadsetPlugged = intent.getIntExtra("state", 0) == 1; } } } } } public class VolumeTrackingService extends Service { private static final String TAG = VolumeTrackingService.class.getSimpleName(); public static final String ACTION_START = "VolumeTrackingService.ACTION_START"; public static final String ACTION_STOP = "VolumeTrackingService.ACTION_STOP"; HeadsetPlugIntentReceiview mHeadsetPlugReceiview; private static boolean mHeadsetPlugged = false; private SettingsContentObserview mSettingsContentObserview; @Nullable @Oviewride public IBinder onBind(Intent intent) { return null; } @Oviewride public void onCreate() { super.onCreate(); mHeadsetPlugReceiview = new HeadsetPlugIntentReceiview(); registerReceiview(mHeadsetPlugReceiview, new IntentFilter(Intent.ACTION_HEADSET_PLUG)); mSettingsContentObserview = new SettingsContentObserview(new Handler()); getApplicationContext().getContentResolview().registerContentObserview(android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserview); } @Oviewride public void onDestroy() { getApplicationContext().getContentResolview().unregisterContentObserview(mSettingsContentObserview); unregisterReceiview(mHeadsetPlugReceiview); super.onDestroy(); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { if (intent != null) { String actionRequested = intent.getAction(); if (ACTION_START.equals(actionRequested)) { } else if (ACTION_STOP.equals(actionRequested)) { stopSelf(); } } return START_STICKY; } private int getSystemVolumeInPercentage() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); final int streamVolumeMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); final int streamVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); return 100 * streamVolume / streamVolumeMax; } private void setHeadphonesVolume(int volumeInPercentage) { // there should be magic of wired headphones volume level changing } private void processVolumeChanges() { if (mHeadsetPlugged) { int systemVolumeInPercentage = getSystemVolumeInPercentage(); setHeadphonesVolume(systemVolumeInPercentage); } } public class SettingsContentObserview extends ContentObserview { public SettingsContentObserview(Handler handler) { super(handler); } @Oviewride public boolean deliviewSelfNotifications() { return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); if (mHeadsetPlugged ) { processVolumeChanges(); } } } public class HeadsetPlugIntentReceiview extends android.content.BroadcastReceiview { @Oviewride public void onReceive(Context ctx, Intent intent) { if (intent.getAction().equals(android.media.AudioManager.ACTION_HEADSET_PLUG)) { mHeadsetPlugged = intent.getIntExtra("state", 0) == 1; } } } } } public class VolumeTrackingService extends Service { private static final String TAG = VolumeTrackingService.class.getSimpleName(); public static final String ACTION_START = "VolumeTrackingService.ACTION_START"; public static final String ACTION_STOP = "VolumeTrackingService.ACTION_STOP"; HeadsetPlugIntentReceiview mHeadsetPlugReceiview; private static boolean mHeadsetPlugged = false; private SettingsContentObserview mSettingsContentObserview; @Nullable @Oviewride public IBinder onBind(Intent intent) { return null; } @Oviewride public void onCreate() { super.onCreate(); mHeadsetPlugReceiview = new HeadsetPlugIntentReceiview(); registerReceiview(mHeadsetPlugReceiview, new IntentFilter(Intent.ACTION_HEADSET_PLUG)); mSettingsContentObserview = new SettingsContentObserview(new Handler()); getApplicationContext().getContentResolview().registerContentObserview(android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserview); } @Oviewride public void onDestroy() { getApplicationContext().getContentResolview().unregisterContentObserview(mSettingsContentObserview); unregisterReceiview(mHeadsetPlugReceiview); super.onDestroy(); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { if (intent != null) { String actionRequested = intent.getAction(); if (ACTION_START.equals(actionRequested)) { } else if (ACTION_STOP.equals(actionRequested)) { stopSelf(); } } return START_STICKY; } private int getSystemVolumeInPercentage() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); final int streamVolumeMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); final int streamVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); return 100 * streamVolume / streamVolumeMax; } private void setHeadphonesVolume(int volumeInPercentage) { // there should be magic of wired headphones volume level changing } private void processVolumeChanges() { if (mHeadsetPlugged) { int systemVolumeInPercentage = getSystemVolumeInPercentage(); setHeadphonesVolume(systemVolumeInPercentage); } } public class SettingsContentObserview extends ContentObserview { public SettingsContentObserview(Handler handler) { super(handler); } @Oviewride public boolean deliviewSelfNotifications() { return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); if (mHeadsetPlugged ) { processVolumeChanges(); } } } public class HeadsetPlugIntentReceiview extends android.content.BroadcastReceiview { @Oviewride public void onReceive(Context ctx, Intent intent) { if (intent.getAction().equals(android.media.AudioManager.ACTION_HEADSET_PLUG)) { mHeadsetPlugged = intent.getIntExtra("state", 0) == 1; } } } } } public class VolumeTrackingService extends Service { private static final String TAG = VolumeTrackingService.class.getSimpleName(); public static final String ACTION_START = "VolumeTrackingService.ACTION_START"; public static final String ACTION_STOP = "VolumeTrackingService.ACTION_STOP"; HeadsetPlugIntentReceiview mHeadsetPlugReceiview; private static boolean mHeadsetPlugged = false; private SettingsContentObserview mSettingsContentObserview; @Nullable @Oviewride public IBinder onBind(Intent intent) { return null; } @Oviewride public void onCreate() { super.onCreate(); mHeadsetPlugReceiview = new HeadsetPlugIntentReceiview(); registerReceiview(mHeadsetPlugReceiview, new IntentFilter(Intent.ACTION_HEADSET_PLUG)); mSettingsContentObserview = new SettingsContentObserview(new Handler()); getApplicationContext().getContentResolview().registerContentObserview(android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserview); } @Oviewride public void onDestroy() { getApplicationContext().getContentResolview().unregisterContentObserview(mSettingsContentObserview); unregisterReceiview(mHeadsetPlugReceiview); super.onDestroy(); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { if (intent != null) { String actionRequested = intent.getAction(); if (ACTION_START.equals(actionRequested)) { } else if (ACTION_STOP.equals(actionRequested)) { stopSelf(); } } return START_STICKY; } private int getSystemVolumeInPercentage() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); final int streamVolumeMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); final int streamVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); return 100 * streamVolume / streamVolumeMax; } private void setHeadphonesVolume(int volumeInPercentage) { // there should be magic of wired headphones volume level changing } private void processVolumeChanges() { if (mHeadsetPlugged) { int systemVolumeInPercentage = getSystemVolumeInPercentage(); setHeadphonesVolume(systemVolumeInPercentage); } } public class SettingsContentObserview extends ContentObserview { public SettingsContentObserview(Handler handler) { super(handler); } @Oviewride public boolean deliviewSelfNotifications() { return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); if (mHeadsetPlugged ) { processVolumeChanges(); } } } public class HeadsetPlugIntentReceiview extends android.content.BroadcastReceiview { @Oviewride public void onReceive(Context ctx, Intent intent) { if (intent.getAction().equals(android.media.AudioManager.ACTION_HEADSET_PLUG)) { mHeadsetPlugged = intent.getIntExtra("state", 0) == 1; } } } } } public class VolumeTrackingService extends Service { private static final String TAG = VolumeTrackingService.class.getSimpleName(); public static final String ACTION_START = "VolumeTrackingService.ACTION_START"; public static final String ACTION_STOP = "VolumeTrackingService.ACTION_STOP"; HeadsetPlugIntentReceiview mHeadsetPlugReceiview; private static boolean mHeadsetPlugged = false; private SettingsContentObserview mSettingsContentObserview; @Nullable @Oviewride public IBinder onBind(Intent intent) { return null; } @Oviewride public void onCreate() { super.onCreate(); mHeadsetPlugReceiview = new HeadsetPlugIntentReceiview(); registerReceiview(mHeadsetPlugReceiview, new IntentFilter(Intent.ACTION_HEADSET_PLUG)); mSettingsContentObserview = new SettingsContentObserview(new Handler()); getApplicationContext().getContentResolview().registerContentObserview(android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserview); } @Oviewride public void onDestroy() { getApplicationContext().getContentResolview().unregisterContentObserview(mSettingsContentObserview); unregisterReceiview(mHeadsetPlugReceiview); super.onDestroy(); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { if (intent != null) { String actionRequested = intent.getAction(); if (ACTION_START.equals(actionRequested)) { } else if (ACTION_STOP.equals(actionRequested)) { stopSelf(); } } return START_STICKY; } private int getSystemVolumeInPercentage() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); final int streamVolumeMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); final int streamVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); return 100 * streamVolume / streamVolumeMax; } private void setHeadphonesVolume(int volumeInPercentage) { // there should be magic of wired headphones volume level changing } private void processVolumeChanges() { if (mHeadsetPlugged) { int systemVolumeInPercentage = getSystemVolumeInPercentage(); setHeadphonesVolume(systemVolumeInPercentage); } } public class SettingsContentObserview extends ContentObserview { public SettingsContentObserview(Handler handler) { super(handler); } @Oviewride public boolean deliviewSelfNotifications() { return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); if (mHeadsetPlugged ) { processVolumeChanges(); } } } public class HeadsetPlugIntentReceiview extends android.content.BroadcastReceiview { @Oviewride public void onReceive(Context ctx, Intent intent) { if (intent.getAction().equals(android.media.AudioManager.ACTION_HEADSET_PLUG)) { mHeadsetPlugged = intent.getIntExtra("state", 0) == 1; } } } } } public class VolumeTrackingService extends Service { private static final String TAG = VolumeTrackingService.class.getSimpleName(); public static final String ACTION_START = "VolumeTrackingService.ACTION_START"; public static final String ACTION_STOP = "VolumeTrackingService.ACTION_STOP"; HeadsetPlugIntentReceiview mHeadsetPlugReceiview; private static boolean mHeadsetPlugged = false; private SettingsContentObserview mSettingsContentObserview; @Nullable @Oviewride public IBinder onBind(Intent intent) { return null; } @Oviewride public void onCreate() { super.onCreate(); mHeadsetPlugReceiview = new HeadsetPlugIntentReceiview(); registerReceiview(mHeadsetPlugReceiview, new IntentFilter(Intent.ACTION_HEADSET_PLUG)); mSettingsContentObserview = new SettingsContentObserview(new Handler()); getApplicationContext().getContentResolview().registerContentObserview(android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserview); } @Oviewride public void onDestroy() { getApplicationContext().getContentResolview().unregisterContentObserview(mSettingsContentObserview); unregisterReceiview(mHeadsetPlugReceiview); super.onDestroy(); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { if (intent != null) { String actionRequested = intent.getAction(); if (ACTION_START.equals(actionRequested)) { } else if (ACTION_STOP.equals(actionRequested)) { stopSelf(); } } return START_STICKY; } private int getSystemVolumeInPercentage() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); final int streamVolumeMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); final int streamVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); return 100 * streamVolume / streamVolumeMax; } private void setHeadphonesVolume(int volumeInPercentage) { // there should be magic of wired headphones volume level changing } private void processVolumeChanges() { if (mHeadsetPlugged) { int systemVolumeInPercentage = getSystemVolumeInPercentage(); setHeadphonesVolume(systemVolumeInPercentage); } } public class SettingsContentObserview extends ContentObserview { public SettingsContentObserview(Handler handler) { super(handler); } @Oviewride public boolean deliviewSelfNotifications() { return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); if (mHeadsetPlugged ) { processVolumeChanges(); } } } public class HeadsetPlugIntentReceiview extends android.content.BroadcastReceiview { @Oviewride public void onReceive(Context ctx, Intent intent) { if (intent.getAction().equals(android.media.AudioManager.ACTION_HEADSET_PLUG)) { mHeadsetPlugged = intent.getIntExtra("state", 0) == 1; } } } } } public class VolumeTrackingService extends Service { private static final String TAG = VolumeTrackingService.class.getSimpleName(); public static final String ACTION_START = "VolumeTrackingService.ACTION_START"; public static final String ACTION_STOP = "VolumeTrackingService.ACTION_STOP"; HeadsetPlugIntentReceiview mHeadsetPlugReceiview; private static boolean mHeadsetPlugged = false; private SettingsContentObserview mSettingsContentObserview; @Nullable @Oviewride public IBinder onBind(Intent intent) { return null; } @Oviewride public void onCreate() { super.onCreate(); mHeadsetPlugReceiview = new HeadsetPlugIntentReceiview(); registerReceiview(mHeadsetPlugReceiview, new IntentFilter(Intent.ACTION_HEADSET_PLUG)); mSettingsContentObserview = new SettingsContentObserview(new Handler()); getApplicationContext().getContentResolview().registerContentObserview(android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserview); } @Oviewride public void onDestroy() { getApplicationContext().getContentResolview().unregisterContentObserview(mSettingsContentObserview); unregisterReceiview(mHeadsetPlugReceiview); super.onDestroy(); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { if (intent != null) { String actionRequested = intent.getAction(); if (ACTION_START.equals(actionRequested)) { } else if (ACTION_STOP.equals(actionRequested)) { stopSelf(); } } return START_STICKY; } private int getSystemVolumeInPercentage() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); final int streamVolumeMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); final int streamVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); return 100 * streamVolume / streamVolumeMax; } private void setHeadphonesVolume(int volumeInPercentage) { // there should be magic of wired headphones volume level changing } private void processVolumeChanges() { if (mHeadsetPlugged) { int systemVolumeInPercentage = getSystemVolumeInPercentage(); setHeadphonesVolume(systemVolumeInPercentage); } } public class SettingsContentObserview extends ContentObserview { public SettingsContentObserview(Handler handler) { super(handler); } @Oviewride public boolean deliviewSelfNotifications() { return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); if (mHeadsetPlugged ) { processVolumeChanges(); } } } public class HeadsetPlugIntentReceiview extends android.content.BroadcastReceiview { @Oviewride public void onReceive(Context ctx, Intent intent) { if (intent.getAction().equals(android.media.AudioManager.ACTION_HEADSET_PLUG)) { mHeadsetPlugged = intent.getIntExtra("state", 0) == 1; } } } } 

    infelizmente não resolve o problema principal: mudair o nível de volume de fones de ouvido com fio (provavelmente é impossível sem "Philips Android TV API").

    Mas se o seu sistema de som surround tiview controle remoto Você pode fazer alguma solução: emulair commands de controle remoto do sistema de som no Service descrito acima e enviá-lo através do dongle IR conectado ao host USB da sua TV Philips 49PUS6401 Android.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.