android - Alarm Manager showing abnormality -
I have installed an alarm manager that will show notifications after 10 seconds after the app is destroyed.
But it is not working.
Here's my code OnDestroy (): and here is alarmManager.class: and here is Notification.class: * I have been working on it for several days, but I am unable to get it. Any help highly appreciated * . Thanks in advance. There are a few small changes to make, but overall you Found the required code. As the status message, you can think more about this: It would also be better to rename your
@Override public void OnDestroy () {super.onDestroy (); MyIntent = new intent (this, alarm manager class); Pending pending vertical aliens = pending. Gatebodestext (this, 0, my intent, 0); AlarmManager AlarmManager = (AlarmManager) getSystemService (ALARM_SERVICE); //alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis (pending, Pending); AlarmManager.Settering (Alarm Manager. RTC_wekup, 10 * 1000, 10 * 1000, Pending Instant); AlarmManager.cancel (pendingIntent); }
public class alarmManager extends BroadcastReceiver {@Override public void onReceive (REFERENCES , Intent to intent) {intent to serve 1 = new intent (context, notification class); Context.startService (Service1); }}
public class extends Service {@Override public void OnCreate (notification) {Super.onCreate (); Intent chief device = new intent (this, main square); Notification Manager Information Manager = (Information Manager) this.getSystemService (context.NOTIFICATION_SERVICE); android.app.Notification gram = new NotificationCompat.Builder (it) .setAutoCancel (right) .setContentIntent (PendingIntent.getActivity (it, 0, mainIntent, PendingIntent.FLAG_UPDATE_CURRENT)) .setContentTitle ( "title") .setContentText ( "it been so long !!! ") .setSubText (" Please return to the application ") .setSound (RingtoneManager.getDefaultUri (RingtoneManager.TYPE_NOTIFICATION)) .setVibrate (new long [] {1000,1000,1000,1000} ) .setSmallIcon (R.drawable.ic_launcher) .setTicker ("Important Notice") .setWhen (System.currentTimeMillis ()) .build (); Information Manager Notice (0, notice); }
service
take the code to make the notification to
Broadcast Receiver Go and replace
this with
context everywhere.
broadcaster receiver is listed in the manifest.
setRepeating () for alarms; Use the
set ()
AlarmManagerTankel (Pending Instant);
broadcast receiver class. Maybe to be consistent with some Java class naming conventions like
AlarmReceiver , and AlarmManager class to avoid confusion.
Comments
Post a Comment