Is there any way to determine that a vibration event has occurred on the phone? No matter which application used vibration.

  • one
    Try to increase the vibration, so that the phone moves at a speed of 3-4 centimeters per second; add a location listener by GPS (the most accurate); and as soon as the location of the phone changes, you can immediately know: the phone vibrates. : D - nick
  • And by the way, make a location in height from the center of the earth, suddenly the phone from the table fell. It means exactly vibration. - nick

2 answers 2

Unfortunately this is not possible. This question is also asked here .

Perhaps, somewhere in nature, there are some frauds with system files, firmware and other things. It is necessary to search on the Internet. Not so simple as it seems.

    In the manifest:

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> 

    This is the AsyncTask :

      public class MyTask extends AsyncTask<Void, String, Void>{ @Override protected void onPreExecute() { super.onPreExecute(); } @Override protected void onPostExecute(Void aVoid) { mTextView.setText("УРАА!!! Телефон вибрирует"); super.onPostExecute(aVoid); } @Override protected Void doInBackground(Void... voids) { boolean isVibration = true; while (isVibration){ try { TimeUnit.MILLISECONDS.sleep(200); BufferedReader bufferedReader = new BufferedReader(new FileReader("/sys/class/timed_output/vibrator/enable")); String str = ""; while ((str = bufferedReader.readLine()) != null){ if (!str.equals("0")) isVibration = false; } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } return null; } } 

    On my phone (android 5.1, root rights) works. Request: test on other devices.

    • Android 4.4.2, such a file exists. Only, for some reason, always the value 0. Strange. - nick
    • tested on android 5.0 without root rights. Works. Probably it rolls only with version 5. - Frozik6k
    • There the value is always 0. It changes only at the moment of vibration, by the number of milliseconds remaining. It is necessary to check in a separate stream all the time until the vibration works. Only now it probably eats battery power. - Frozik6k
    • I agree. But we really need to check it out. - nick