Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6447cac

Browse files
Finishing Notification
1 parent c51773e commit 6447cac

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

‎app/src/main/AndroidManifest.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools">
44

5+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
56
<application
67
android:allowBackup="true"
78
android:dataExtractionRules="@xml/data_extraction_rules"

‎app/src/main/java/it/ezzie/smartalarm/Alarm_Receiver/AlarmReceiver.java‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
import android.content.Context;
77
import android.content.Intent;
88
import android.net.Uri;
9-
109
import androidx.core.app.NotificationCompat;
11-
1210
import it.ezzie.smartalarm.R;
1311

1412
public class AlarmReceiver extends BroadcastReceiver {
@@ -28,14 +26,19 @@ private void createChannel(Context context , String alarmLabel){
2826
//Create Ringtone
2927
Uri ringtoneUri = Uri.parse("android.resource://" + context.getPackageName() + "/" + R.raw.playing_god);
3028
//Creating Notification Channel
31-
NotificationChannel notificationChannel = new NotificationChannel(channelId,"Alarm Notification", NotificationManager.IMPORTANCE_HIGH);
32-
notificationChannel.setSound(ringtoneUri,null);
29+
NotificationChannel notificationChannel = new NotificationChannel(channelId,"Alarm Notification", NotificationManager.IMPORTANCE_HIGH);
30+
notificationChannel.setSound(ringtoneUri,null);
3331
//Creating Notification Manager
3432
NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
3533
notificationManager.createNotificationChannel(notificationChannel);
3634
//Creating Notification Builder
37-
NotificationCompat.Builder builder = new NotificationCompat.Builder(context,channelId)
38-
.
35+
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelId)
36+
.setContentTitle("Alarm")
37+
.setContentText(alarmLabel)
38+
.setSmallIcon(R.drawable.alarm_Icon)
39+
.setPriority(NotificationCompat.PRIORITY_HIGH);
40+
41+
notificationManager.notify(1, builder.build());
3942
}
4043
}
4144
}
4.81 KB
Loading[フレーム]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /