Android vibrate+ 振动

------------
package Vibrate.co.cc;
import net.youmi.android.AdManager;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Service;
import android.os.Bundle;
import android.os.Vibrator;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
public class VibrateActivity extends Activity {
Vibrator mVibrator;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
AdManager.init(VibrateActivity.this, "3b60834d4add6b84",
"d97f2525530fc5d9", 30, false);
setContentView(R.layout.main);
mVibrator = (Vibrator) getApplication().getSystemService(
Service.VIBRATOR_SERVICE);
Button mButton1 = (Button) findViewById(R.id.button1);
mButton1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
mVibrator.vibrate(new long[] { 10, 50, 10 }, 0);
}
});
findViewById(R.id.button4).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
mVibrator.vibrate(new long[] { 100, 100, 100, 1000 }, 0);
}
});
findViewById(R.id.button2).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
mVibrator.vibrate(new long[] { 1, 1, 1, 1 }, 0);
}
});
findViewById(R.id.button6).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
mVibrator.cancel();
}
});
findViewById(R.id.button5).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
mVibrator.vibrate(new long[] { 100, 100, 100, 100 }, 0);
}
});
findViewById(R.id.button3).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
mVibrator.vibrate(new long[] { 10, 10, 10, 10 }, 0);
}
});
findViewById(R.id.button7).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
// mVibrator.vibrate(new long[] { 1, 1, 1, 1 }, 0);
// 机关枪式按摩
// mVibrator.vibrate(new long[] { 10, 100, }, 0);
// 抖动式按摩
// mVibrator.vibrate(new long[] { 10,50,10}, 0);
mVibrator.vibrate(new long[] { 100, 50, 100, 50 }, 0);
}
});
findViewById(R.id.button8).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
// mVibrator.vibrate(new long[] { 0,20,40,60,0}, 0);
mVibrator.vibrate(new long[] { 25, 25 }, 0);
}
});
findViewById(R.id.button10).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
mVibrator.vibrate(new long[] { 45, 45 }, 0);
}
});
}

public boolean onCreateOptionsMenu(Menu menu)
{
// TODO Auto-generated method stub
SubMenu subMenu = menu.addSubMenu(0, 1, 0, "关于");
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
// TODO Auto-generated method stub
AlertDialog.Builder builder = new Builder(VibrateActivity.this);
builder.setTitle("手机震动按摩");
builder.setMessage(R.string.about);
builder.create().show();
return super.onOptionsItemSelected(item);
}
}
--------------------

你可能感兴趣的:(android)