How to check if vibration happened, in logcat?

那年仲夏 提交于 2020-01-21 12:15:45

问题


I searched in the web but i couldn find a single article dealing in a straight forward way on how to find the vibrate on/off logs in logcat. If anybody who is aware of the procedure, please enlighten me. Once again i need it specifically to check if my app triggers vibrator or not...


回答1:


Vibration data is not logged by default. Fortunately, there is some code in HardwareServices.java that can be enabled to provide exactly what you want. Keep in mind that since this is part of the framework, changing it will require you to rebuild and reflash your device. If you are running on an ADP or the emulator this should be easy. It might be a bit more challenging if you are doing this on another device.

Locate the following code and replace false with true and you should be all set.

        if (false) {
            String s = "";
            int N = pattern.length;
            for (int i=0; i<N; i++) {
                s += " " + pattern[i];
            }
            Log.i(TAG, "vibrating with pattern: " + s);
        }


来源:https://stackoverflow.com/questions/3026861/how-to-check-if-vibration-happened-in-logcat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!