[英]Is It possible to turn all the vibrations of the phone off using Android / Flutter?
我需要关闭手机的所有振动,即指纹、通知、键盘敲击、充电器进出、密码错误和任何其他振动。 是否可以使用 Java/Kotlin 在 Android 上实现,或者如果在 Flutter 上可以实现会更好。
谢谢,
对于振动电话,可以使用 flutter 振动 package(链接: https://pub.dev/packages/vibration )。 这是简单的演示代码。 确保您在 pubspec.yaml 依赖项中添加了振动 package 并使用此权限更新 AndroidManifest.xml
<uses-permission android:name="android.permission.VIBRATE"/>
import 'package:flutter/material.dart';
import 'package:vibration/vibration.dart';
void main() => runApp(VibratingApp());
class VibratingApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Vibration Plugin example app'),
),
body: RaisedButton(
child: Text('Vibrate for default 500ms'),
onPressed: () {
Vibration.vibrate();
},
)));
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.