-1
「構造函數意圖(EAlarmReceiver,Class)未定義」是什麼意思?這是使用短信觸發鬧鐘的正確方法,而且即使在靜音模式下,我仍能如何啓動鬧鐘?在此先感謝使用短信觸發報警
public class EAlarmReceiver extends BroadcastReceiver {
public static String sender;
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Bundle bundle = intent.getExtras();
Object[] pdusObj = (Object[]) bundle.get("pdus");
SmsMessage[] messages = new SmsMessage[pdusObj.length];
for (int i = 0; i<pdusObj.length; i++)
{
messages[i] = SmsMessage.createFromPdu ((byte[])
pdusObj[i]);
sender = messages[i].getOriginatingAddress();
}
for (SmsMessage msg : messages) {
if (msg.getMessageBody().contains("alert")) {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.SECOND, 1);
Intent i = new Intent(EAlarmReceiver.this, ReceiverInterface.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context,
12345, i, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager am =
(AlarmManager)context.getSystemService(Activity.ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(),
pendingIntent);
}//end if
}//end for
}// end onreceive