I am making one application and opening alertdialog using OnLongClickListener of ImageView and also ontouch zooming. But when I pressed long than vibrating on so is it possible to turn off vibrating on long click listener. I am using below code:
public OnLongClickListener longClick = new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Vibrator vibe = (Vibrator)DailySatsangActivity.this.getSystemService(Context.VIBRATOR_SERVICE) ;
vibe.cancel();
}
};
I think the problem you are facing is Haptic Feedback instead of the normal vibration.
You can turn-off "Haptic Feedback" by using below code,
XML attribute: android:hapticFeedbackEnabled //set it true or false in view's xml file for the desired result.
Java method: setHapticFeedbackEnabled(boolean)
OR
You can use Audio Manger class to disable sound and vibration, have a look at setRingerMode method of Audio Manager class.
Example :
AudioManager aManager=(AudioManager)getSystemService(AUDIO_SERVICE);
aManager.setRingerMode(aManager.RINGER_MODE_SILENT);
Hope this will solve your problem.
您应该为此使用AudioManager类。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.