0

Used the following:

How to enable haptic feedback on button view

import android.view.View;
import android.os.Vibrator;

public class Main extends Activity implements OnClickListener
{
    private View myView;
    private Vibrator myVib;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        myVib = (Vibrator) this.getSystemService(VIBRATOR_SERVICE);

        //myView can be any type of view, button, etc.
        myView = (View) this.findViewById(R.id.myView);
        myView.setOnClickListener(this);
    }

    @Override
    public void onClick(View v)
    {
        myVib.vibrate(50);
        //add whatever you want after this
    }
}

The error occurs on the following line: myView.setOnClickListener(this);

Button haptic feedback vibration only works on personal device and not on devices that download from the Google Play Store.

The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the arguments (MainActivity)

Community
  • 1
  • 1
Skyfall
  • 35
  • 7

0 Answers0