Привет, я пытаюсь сделать это, когда пользователь нажимает на кнопку, телефон вибрирует. Heres manifest.xml и AndroidVibrator.java, так что не так? как я могу это исправить? благодаря!Почему мой телефон не вибрирует, когда я нажимаю кнопку?
Heres файл манифеста:
<?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>
Heres 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
@Manik Я только начал использовать vibes в своем приложении и опробовал отключить вибрации на моем телефоне, чтобы кнопки на задней и домашней странице не зависали, но мое приложение все еще ... мне нужно проверить, есть ли у телефона пользователя в настоящее время vibes отключены, а не vibe? – topwik
@towpse, какое событие вашего приложения оценивается? Клавиатура Нажмите или обычное касание на виды? – Mani