Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing channel id in motivation notifications #133

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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