Remove All Ads from XDA

[GUIDE] Customizing Sony W. Button behaviour

1 posts
Thanks Meter: 0
By mazze1200, Junior Member on 12th January 2014, 07:18 PM
Post Reply Email Thread
I recently got an SONY NWZ-F806 Walkman with Android. I bought it to listen to Spotify and everything works fine but the fact that you cannot control Spotify with the the dedicated W. button on the side of the device.

So I googled and found a solution where you had to redirect the W. button to the search button which was not satisfying to me. So I decided to investigate deeper into this and with a little help of adb and dumpsys I found the Intent that was fired when the W. button is pressed " ". Than I found the service which was responsible for the default behavior "W.control".

So to redirect the W. button to Spotify I had to do the following things:

1) Disable the default W. behavior
To do this you simply have to deactivate the W.control service
Systemsettings > Apps > All > W.control > Disable

2) To listen to the W. button a BroadcastReceiver has to be implemented which receives to the Intent " " and sends a Intent to Spotify

        <receiver android:name=".WDotReceiver" >
                <action android:name="" />
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;

public class WDotReceiver extends BroadcastReceiver {
	private static final String KEY_EVENT_KEY = "android.intent.extra.KEY_EVENT";
	private static final String SPOTIFY_PLAY_KEY = "";
	private static final String SPOTIFY_NEXT_KEY = "";

	public void onReceive(Context arg0, Intent arg1) {
		Bundle extrasBundle =  arg1.getExtras();
		if(extrasBundle != null)
				KeyEvent keyEvent =  extrasBundle.getParcelable(KEY_EVENT_KEY);
				if(keyEvent.getAction() == KeyEvent.ACTION_DOWN && keyEvent.getRepeatCount() == 0)
					arg0.sendBroadcast(new Intent(SPOTIFY_PLAY_KEY));
				else if(keyEvent.getAction() == KeyEvent.ACTION_DOWN && keyEvent.getRepeatCount() == 1)
					arg0.sendBroadcast(new Intent(SPOTIFY_NEXT_KEY));
If you press the W. button for a short time a Play/Pause Intent is send and if you press the button longer Spotify will skip to the next track.

To me this increases the usability of the device tremendously.

Kind regards
13th January 2014, 04:12 AM |#2  
Thanks Meter: 0
wrong forum bro
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes