Setting. I would like to make my phone vibrate when a button is clicked. I use the code of SO question: How to make an Android device vibrate?.
The code to let the phone vibrate:
@Override
public void onClick (View view)
{
Vibrator vibrator = (Vibrator) MyActivity.this.getSystemService (Context.VIBRATOR_SERVICE);
if (vibrator.hasVibrator()) {
Log.v ("Can Vibrate", "YES");
} else {
Log.v("Can Vibrate", "NO");
}
vibrator.vibrate (1000);
}
I also added the permission
<uses-permission android:name="android.permission.VIBRATE"/>
to the manifest file.
Problem. The phone does not vibrate at all upon button click. Other apps on my phone make the phone vibrate.
Log messages.
xxxx V/Can Vibrate﹕ YES
xxxx V/Vibrator﹕ Called vibrate(long) API - PUID: 10060, PackageName: de.creamin.vibratetest
xxxx V/Vibrator﹕ vibrate - PUID: 10060, PackageName: de.creamin.vibratetest, ms: 1000, mag: -1
Phone. Samsung Galaxy S3 (GT-I9300), Android 4.3
Question. What is going on here? Do I have to configure my phone somehow to accept the vibration code?