标签:
// 设置定时
private void setSleep() {
// 设置一次性的闹钟
Intent intent = new Intent(getActivity(), MusicBroadcastReceiver.class);
intent.putExtra("toReceiver", "我是碎片发到广播的");
PendingIntent pIntent = PendingIntent.getBroadcast(getActivity(), 0,
intent, 0);
long time=SystemClock.elapsedRealtime() + Integer.parseInt(et_time.getText().toString());
// 设置闹钟
AlarmManager manager = (AlarmManager) getActivity().getSystemService(
getActivity().ALARM_SERVICE);
manager.set(AlarmManager.RTC_WAKEUP, time, pIntent);
}
标签:
原文地址:http://www.cnblogs.com/wangfeng520/p/5113458.html