简体   繁体   中英

Is It possible to turn all the vibrations of the phone off using Android / Flutter?

I need to turn off all the vibrations of the phone ie fingerprint, notifications, keyboard tap, charger in and out, wrong password and any other vibration there is. Is it possible on Android using Java/Kotlin, or It will be better if it is possible on Flutter.

Thanks,

For vibrating phone one can use flutter vibration package (Link: https://pub.dev/packages/vibration ). Here is simple demo code. Make sure that you have add vibration package in your pubspec.yaml dependencies and also update the AndroidManifest.xml with this permission

<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();
          },
        )));
     }
  }

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM