Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,805,635 Members 38,718 Now Online
XDA Developers Android and Mobile Development Forum

[GUIDE] Customizing Sony W. Button behaviour

Tip us?
Junior Member - OP
Thanks Meter 0
Posts: 1
Join Date: Jun 2009
Default [GUIDE] Customizing Sony W. Button behaviour

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
yamin8000's Avatar
Senior Member
Thanks Meter 195
Posts: 452
Join Date: May 2012
Location: Gorgan
wrong forum bro
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes