Skip to content

Commit

Permalink
Merge pull request #133 from morckx/fix-motivation-alerts
Browse files Browse the repository at this point in the history
Add missing channel id in motivation notifications
  • Loading branch information
udenr authored Jan 23, 2024
2 parents b8b6ad4 + 17e518c commit e705e03
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
*/
package org.secuso.privacyfriendlyactivitytracker.receivers;

import static org.secuso.privacyfriendlyactivitytracker.services.AbstractStepDetectorService.CHANNEL_ID;

import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
Expand All @@ -34,6 +37,7 @@

import org.secuso.privacyfriendlyactivitytracker.Factory;
import org.secuso.privacyfriendlyactivitytracker.R;
import org.secuso.privacyfriendlyactivitytracker.activities.MainActivity;
import org.secuso.privacyfriendlyactivitytracker.persistence.StepCountPersistenceHelper;
import org.secuso.privacyfriendlyactivitytracker.services.AbstractStepDetectorService;
import org.secuso.privacyfriendlyactivitytracker.utils.StepDetectionServiceHelper;
Expand Down Expand Up @@ -127,12 +131,18 @@ private void motivate() {
Collections.shuffle(motivationTexts);
String motivationText = motivationTexts.get(0);

Intent intent = new Intent(context, MainActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE);

// Build the notification
NotificationManager notificationManager = (NotificationManager) context.getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context.getApplicationContext())
.setSmallIcon(R.drawable.ic_walk_black_24dp)
.setContentTitle(context.getString(R.string.motivation_alert_notification_title))
.setAutoCancel(true)
.setChannelId(CHANNEL_ID)
.setContentIntent(pIntent)
.setContentText(motivationText)
.setSound(Settings.System.DEFAULT_NOTIFICATION_URI)
.setLights(ContextCompat.getColor(context, R.color.colorPrimary), 1000, 1000);
Expand Down

0 comments on commit e705e03

Please sign in to comment.