如何设置在Android程序code手机报警 [英] How to set phone's alarm from program code in Android

查看:142
本文介绍了如何设置在Android程序code手机报警的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置的手机报警电话。
任何人都可以说该怎么办?

I want to set phones alarm in phone. Can anybody say how to do that?

我从网上code和尝试,但在alram未设置为手机。

I got the code from net, and try but the alram not set to phone.

Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
Intent activate = new Intent(this, Alaram.class);
AlarmManager alarams ;
PendingIntent alarmIntent = PendingIntent.getBroadcast(this, 0, activate, 0);
alarams = (AlarmManager) getSystemService(ALARM_SERVICE);
alarams.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), alarmIntent);

在此code,我们提供意向为 Alaram.class。
那么应该怎样写在这个 Alram.class 使报警设置移动。

In this code we are provide intent as Alaram.class. Then what should be written in this Alram.class so that alarm will set to the mobile.

推荐答案

我想你是误会什么的 AlarmManager 是好的。它开始于一个给定的点code,它不设置手机铃声。

I think you misunderstood what the AlarmManager is good for. It starts your code on a given Point, it doesn't set the phones ring tone.

如果你想设置的电话报警声,这可能是有帮助的(<一个href=\"https://github.com/android/platform_packages_apps_music/blob/03fbe7dfb76315abf0abf76cdb33d643f4f595dc/src/com/android/music/MediaPlaybackActivity.java#L579\"相对与标准的Andr​​oid音乐播放器 =nofollow的>)

If you want to set the Phones Alarm sound, this might be helpful (from the standard Android Music Player):

// Set the system setting to make this the current ringtone
MusicUtils.setRingtone(this, mService.getAudioId());

这篇关于如何设置在Android程序code手机报警的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆