如何在Android Oreo上振动

编程入门 行业动态 更新时间:2024-10-20 19:01:11
本文介绍了如何在Android Oreo上振动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

自3个星期以来,我一直在搜索,而且我会发疯!我已经尝试了在每个论坛上看到的每个代码,但是我无法在android 8.0上的android应用上震动,我已经用cordova制作了一个应用,我试图用(vibrator)(vibrationeffect)做一个插件,我尝试用android studio制作一个空白的本机应用程序,什么也没有.它仅适用于较低版本的Android.

I'm searching since 3 weeks and I'm going crazy! I have try every code I seen on each forum but i'm not able to have vibration on my android app on android 8.0, I have made an app with cordova, i have try to make a plugin with (vibrator) (vibrationeffect) nothing, i have try to make a blank native app with android studio, nothing. It work only on lower version of Android.

振动对于我的应用程序至关重要,我在使用Android 8的2手机上尝试振动,但我遇到了同样的问题,logcat表示一切正常,navigator.vibrate无法正常工作,因为振动无法触摸(这是一个小游戏)

Vibration is essential for my app and I try it on 2 phone with Android 8 and I have the same problem, logcat say everythings ok, navigator.vibrate don't work because vibrate is not on touch (it's a little game).

我需要你的帮助.

推荐答案

1.)初始化振动器类:

1.) Initialize the Vibrator class:

Vibrator vibrator = (Vibrator) Context.getSystemService(Context.VIBRATOR_SERVICE);

2.)叫振动

vibrator.vibrate(VibrationEffect.createOneShot(30, VibrationEffect.DEFAULT_AMPLITUDE));

更多推荐

如何在Android Oreo上振动

本文发布于:2023-11-27 08:17:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637244.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   Android   Oreo

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!