嗨即时尝试使它,当用户点击按钮手机振动。下面manifest.xml和AndroidVibrator.java所以最新的错误?我该如何解决它?谢谢!当我按下按钮时,为什么手机没有振动?
继承人的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.app"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-sdk android:minSdkVersion="7" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".AndroidActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activity2"
android:screenOrientation="portrait"
android:label="@string/app_name" >
</activity>
<activity android:name=".activity3"
android:screenOrientation="portrait"
android:label="@string/app_name" >
</activity>
<activity android:name=".next" >
</activity>
</application>
</manifest>
继承人AndroidActivity:
package android.app;
import android.app.R;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.view.View;
import android.os.Vibrator;
public class AndroidVibrator extends Activity implements OnClickListener
{
private View myView;
private Vibrator myVib;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
myVib = (Vibrator) this.getSystemService(VIBRATOR_SERVICE);
//myView can be any type of view, button, etc.
myView = (View) this.findViewById(R.id.sound);
myView.setOnClickListener((android.view.View.OnClickListener) this);
}
public void onClick(View v)
{
myVib.vibrate(50);
//add whatever you want after this
}
public void onClick(DialogInterface arg0, int arg1) {
// TODO Auto-generated method stub
}
}
检查手机设置,振动是否被禁用。 – Mani 2012-01-14 06:15:07
@Manik我刚开始在我的应用程序中使用共鸣,并测试关闭我的手机振动,所以后面和主页按钮不会盛传,但我的应用程序仍然...我需要检查用户的手机目前是否有振动禁用,不做氛围? – topwik 2012-09-05 19:03:09
@towpse你的应用程序共鸣哪个事件? 键盘按下或正常触摸视图? – Mani 2012-09-06 06:20:35