Я вставил событие в календарь.Время созданного события также должно быть создано с тревогой того же самого времени, чтобы позвонить.Как это сделать?Я использовал следующий код, и он выдает следующую ошибку.
Я получаю следующую ошибку, когда использую следующий код: Основная активность:
Calendar caln = Calendar.getInstance();
caln.add(Calendar.SECOND, 2);
Intent intent = new Intent(ToDoApplicationActivity.this, AlarmReceiver.class);
intent.putExtra("alarm_message", title1);
PendingIntent sender = PendingIntent.getBroadcast(this, 192837, intent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sender);
startActivity(intent);
Переопределен метод OnReceive:
public void onReceive(Context context, Intent intent) {
try {
Bundle bundle = intent.getExtras();
String message = bundle.getString("alarm_message");
Intent newIntent = new Intent(context, ToDoApplicationActivity.class);
newIntent.putExtra("alarm_message", message);
newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(newIntent);
} catch (Exception e) {
Toast.makeText(context, "There was an error somewhere, but we still received an alarm", Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
ОШИБКА получена:
android.content.ActivityNotFoundException: невозможно найти явный класс активности {com.android.todoapplication / android.todoapplication.AlarmReceiver};Вы объявили об этом действии в вашем AndroidManifest.xml?
Любая помощь высоко ценится и заранее спасибо ...