闹钟的设置
package com.mct.alarmmanagerdemo;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.os.Bundle;
import android.os.Vibrator;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
public class AlarmActivity extends Activity implements OnClickListener {
private Vibrator vb;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
/* 设置为无标题栏 */
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.alarm_activity_layout);
findViewById(R.id.m_close).setOnClickListener(this);
findViewById(R.id.m_delay).setOnClickListener(this);
// 调用震动
vb = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
long[] pattern = { 500, 10, 300, 50 };
// 第一个参数表示震动
vb.vibrate(pattern, 2);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.m_close:
vb.cancel();
finish();
break;
case R.id.m_delay:
vb.cancel();
finish();
break;
}
}
}