Reputation: 51
I'm trying to make an Alarm using the Alarm Manager. The app runs without any error messages, but nothing happens.
I tried solutions from developer.android.com and suggestions from stackoverflow. I also tried copying a complete tutorial i found, but nothing worked.
The app runs on API22 and was tested on an emulator(API23) and a real device(API22).
This is my Code:
MainActivity.java startAlarm():
AlarmManager manager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
Intent myIntent = new Intent(MainActivity.this,AlarmReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this,0,myIntent,0);
manager.set(AlarmManager.RTC_WAKEUP, SystemClock.elapsedRealtime()+3000,pendingIntent);
AlarmReceiver.java:
public class AlarmReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
Toast.makeText(context,"THIS IS MY ALARM",Toast.LENGTH_LONG).show();
}
}
AndroidManifest.xml, between <manifest...>
and </manifest>
:
<receiver android:process=":remote" android:name=".AlarmReceiver"></receiver>
Upvotes: 0
Views: 87
Reputation: 8354
your reciever name is AlarmToastReceiver
not AlarmReceiver
try:
<receiver android:process=":remote" android:name=".AlarmToastReceiver "></receiver>
Upvotes: 2