2

my alarm manager not working on lollipop version when app close while it's working on other Android version marshmallow, Nougat, perfectly

alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
        Intent intent = new Intent(context, AlarmReciver.class);
        intent.putExtra("msg", msgstring);
        intent.putExtra("num", recipstring);
        intent.putExtra("recipname", name);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(context, number, intent, PendingIntent.FLAG_UPDATE_CURRENT);
        alarmManager.set(AlarmManager.RTC_WAKEUP, targetCal.getTimeInMillis(), pendingIntent);``

here is my alarm receiver:

public class AlarmReciver extends WakefulBroadcastReceiver {
@Override  public void onReceive(Context context, Intent intent) {
  Notification.Builder builder= new Notification.Builder(context);
        builder.setAutoCancel(true)
                .setDefaults(Notification.DEFAULT_ALL)
                .setWhen(System.currentTimeMillis()).setColor(Color.WHITE)
                .setSmallIcon(R.mipmap.ic_launcher).setPriority(Notification.PRIORITY_HIGH)
                .setDefaults(Notification.DEFAULT_LIGHTS|Notification.DEFAULT_SOUND)
                .setContentTitle("test")
                .setContentText(message);
        NotificationManager notificationManager=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(1, builder.build());
        dbhelper.insertdilvery(message, name);
}
    }

Manifest file:

   <receiver android:name="com.simulatorgames3d.EventsNotifications.alarmreceiver.AlarmReciver"
            android:process=":remote"
            android:enabled="true"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </receiver>

permissions

<uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>

herr is logcat pic when app not close enter image description here

locat when app close and alrm not fire enter image description here

Bedir Yilmaz
  • 3,823
  • 5
  • 34
  • 54
ateeq
  • 21
  • 3

0 Answers0