Я вставил событие в календарь. Время созданного события также должно быть создано с будильником того же времени, чтобы звонить. Как это сделать? Я использовал следующий код, и он дает следующую ошибку.
Я получаю следующую ошибку, когда использую следующий код: Основное действие:
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?
Любая помощь приветствуется и заранее благодарна...