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 ():

  @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); }   

and here is alarmManager.class:

  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); }}   

and here is Notification.class:

  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); }   

* 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.

  1. You do not need a service take the code to make the notification to Broadcast Receiver Go and replace this with context everywhere.
  2. Make sure your broadcaster receiver is listed in the manifest.
  3. Do not use setRepeating () for alarms; Use the set ()
  4. Remove the following line: AlarmManagerTankel (Pending Instant);

    As the status message, you can think more about this: It would also be better to rename your broadcast receiver class. Maybe to be consistent with some Java class naming conventions like AlarmReceiver , and AlarmManager class to avoid confusion.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -