문제

Does anyone know why my vibrate service is having an error when I click the Buttons? It says "....... force close". Here's my code:

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

public void onClick(View v) {
    Intent newgameIntent = new Intent(BodyPartsGameActivity.this,gamelevel.class);
    startActivity(newgameIntent);
    mp.start();
    mVibrator.vibrate(500);
}
도움이 되었습니까?

해결책

You must specify the permission to use the vibrator. Otherwise the security framework will shut down your application.

<manifest>
    ...
    <uses-permission android:name="android.permission.VIBRATE"/>
    ...
</manifest>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top