8

I want to enable/disable vibration on Sony Smartwatch 2 in my app on some conditions.

Is it possible and if it so how to do that?

EDIT: I mean enable/disable it globally (notifications, incoming calls etc.), as "Vibrate" setting in SW2 menu.

Vladimir Petrakovich
  • 4,184
  • 1
  • 30
  • 46

2 Answers2

1

You might not be able to do this globally.

From the docs, the watch operates on actions from the host.

I don't have a SW2 right now but you can try to trigger the extension when you detect the device is vibrating.

This would be a start:

public class NoVibrator extends ControlExtension{


// stuff....

 @Override
    public void onStart() {
        if(hasVibrator()){
            stopVibrator();
     }
    }

}

But I suspect this only disables vibration in your app.

You might have to find an exploit to change the settings. (something like this)

tom91136
  • 8,662
  • 12
  • 58
  • 74
  • Suddenly `stopVibrator()` just makes vibrator active for some amount of time. It seems that this method can only interrupt vibration with infinite repeats (and only between iterations of on/off cycle). Anyway, thanks for response. – Vladimir Petrakovich May 31 '15 at 20:59
1

I don't know what your conditions are but to control the vibration use these methods in the ControlExtension class:

Start:

ControlExtension.startVibrator(int onDuration, int offDuration, int repeats);

Stop:

ControlExtension.stopVibrator();

Edit 1: There is no way to configure vibration for notifications.

Pete
  • 597
  • 1
  • 8
  • 27