本文介绍了Android的 - 振动设备不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


其实我有一个应用程序,我测试了两个设备。其中LG GW620,和一个三星的角宿一。我想,当用户触摸屏幕时,设备振动。


I actually have an app that I test with two devices. One LG GW620, and one Samsung Spica.I would like when User touch the screen, the device vibrate.

事实上,在LG GW620,当我抚摸它的设备振动。但在角宿一不...

In fact, On the LG GW620, the device vibrate when I touch it. But on the spica doesn't...

我找的人字设置,但振动器的检查,所以我不明白为什么它不振动。

I looked for settings on the spica, but Vibrator is check, so I don't understand why it doesn't vibrate.

在我的应用程序,我有:<使用-权限的Andr​​oid:名称=android.permission.VIBRATE>< /使用-许可>

In my app I have : <uses-permission android:name="android.permission.VIBRATE"></uses-permission>

和在code:

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

不过,我想是不是做的最好的事情。我希望设备振动对每一次点击,但我不知道有没有做一个振动器的每个的OnClick?或者,如果我能为所有的应用程序只做一震动?
尤其是为什么它在角宿一不工作?

But I think it is not the best thing to do that. I wish device vibrate for every click, but I don't know if I have to do a Vibrator for each OnClick ? Or if I could do only one Vibrator for all the application ?
And especially why it doesn't work on Spica ?

推荐答案

滑稽。在你的onClick的按钮,你应该把震动。而且,由于它是在毫秒我把0.1秒像500半秒钟吧。

Funny. In your onClick for the button you should put the vibrate. And since it is in miliseconds I'd put something like 500 for half a second instead of .1 seconds.

void onCreate() {

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

    Button b = (Button) findViewById(R.id.button);
    b.setOnClickListener(new View.OnClickListener() {
        void onClick() {
            mVibrator.vibrate(500);
        }
    });
}

这篇关于Android的 - 振动设备不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 12:40